Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Aug 2021 08:39:08 GMT
From:      "Tobias C. Berner" <tcberner@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 43f4cf91623e - main - x11-toolkits/qt5-gui: add upstream fix to clipboard
Message-ID:  <202108140839.17E8d8GI083443@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by tcberner:

URL: https://cgit.FreeBSD.org/ports/commit/?id=43f4cf91623eaecea287fdc4be9561d833f3dd7f

commit 43f4cf91623eaecea287fdc4be9561d833f3dd7f
Author:     Tobias C. Berner <tcberner@FreeBSD.org>
AuthorDate: 2021-08-14 08:32:46 +0000
Commit:     Tobias C. Berner <tcberner@FreeBSD.org>
CommitDate: 2021-08-14 08:37:43 +0000

    x11-toolkits/qt5-gui: add upstream fix to clipboard
    
    Bug description from [2]:
            QXcbConnection::getTimestamp() returns a timestamp from an
            earlier PropertyNotify event which was already in the event
            queue. I found this issue when I was trying to figure out why
            gvim (with GTK+) exits with a BadWindow error when selecting or
            copying a large text to the clipboard in a KDE environment. It
            turns out that GTK+ uses the INCR protocol to send the data and
            QT uses getTimestamp (in QXcbClipboard::clipboardReadProperty)
            to set the start time of the transfer. Since that start time is
            incorrect QT expects data which hasn't been sent yet and closes
            the window. GTK+ still tries to add the data to the window which
            causes a BadWindow error.
    
    From [1]:
            xcb: add a timeout control when reading INCR property
    
            For the first call of QXcbClipboard::clipboardReadProperty()
            inside of clipboardReadIncrementalProperty() in getSelection(),
            it will get a XCB_NONE reply before the contents arrived via
            property change. Then we give a chance to read more.
    
    Upstream Code Review [1]:
            https://codereview.qt-project.org/c/qt/qtbase/+/364040
    
    Upstream Bug Report [2]:
            https://bugreports.qt.io/browse/QTBUG-56595
---
 x11-toolkits/qt5-gui/Makefile                      |  2 +-
 ...-add_timeout_control_when_reading_incr_property | 59 ++++++++++++++++++++++
 2 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/x11-toolkits/qt5-gui/Makefile b/x11-toolkits/qt5-gui/Makefile
index a49eadb62a48..bc9525794292 100644
--- a/x11-toolkits/qt5-gui/Makefile
+++ b/x11-toolkits/qt5-gui/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	gui
 DISTVERSION=	${QT5_VERSION}
-PORTREVISION=	5
+PORTREVISION=	6
 CATEGORIES=	x11-toolkits graphics
 PKGNAMEPREFIX=	qt5-
 
diff --git a/x11-toolkits/qt5-gui/files/patch-git_73fc1f93-add_timeout_control_when_reading_incr_property b/x11-toolkits/qt5-gui/files/patch-git_73fc1f93-add_timeout_control_when_reading_incr_property
new file mode 100644
index 000000000000..6f6dec7d35ec
--- /dev/null
+++ b/x11-toolkits/qt5-gui/files/patch-git_73fc1f93-add_timeout_control_when_reading_incr_property
@@ -0,0 +1,59 @@
+From 73fc1f93e8bea1c493ed16655ad6fd68ae270e38 Mon Sep 17 00:00:00 2001
+From: Liang Qi <liang.qi@qt.io>
+Date: Wed, 7 Jul 2021 13:19:14 +0200
+Subject: [PATCH] xcb: add a timeout control when reading INCR property
+MIME-Version: 1.0
+Content-Type: text/plain; charset=utf8
+Content-Transfer-Encoding: 8bit
+
+For the first call of QXcbClipboard::clipboardReadProperty()
+inside of clipboardReadIncrementalProperty() in getSelection(),
+it will get a XCB_NONE reply before the contents arrived via
+property change. Then we give a chance to read more.
+
+Manually tested with following setups:
+* examples/widgets/mainwindows/application with gvim(gtk3)
+* examples/widgets/widgets/imageviewer with GIMP 2.10.18(based on
+gtk2) and GIMP 2.99.6(based on gtk3 via flatpak)
+
+Fixes: QTBUG-56595
+Done-With: JiDe Zhang <zhangjide@uniontech.com>
+Change-Id: Ib45f08464d39ad79137b1da99808c89b7dca2d08
+Reviewed-by: JiDe Zhang <zhangjide@uniontech.com>
+Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
+(cherry picked from commit 02248eea5562c1df39ee23f195011afacc6759b0)
+Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
+---
+ src/plugins/platforms/xcb/qxcbclipboard.cpp | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp
+index 725c0e4d514..a4940f1c491 100644
+--- src/plugins/platforms/xcb/qxcbclipboard.cpp
++++ src/plugins/platforms/xcb/qxcbclipboard.cpp
+@@ -841,6 +841,8 @@ QByteArray QXcbClipboard::clipboardReadIncrementalProperty(xcb_window_t win, xcb
+         alloc_error = buf.size() != nbytes+1;
+     }
+ 
++    QElapsedTimer timer;
++    timer.start();
+     for (;;) {
+         connection()->flush();
+         xcb_generic_event_t *ge = waitForClipboardEvent(win, XCB_PROPERTY_NOTIFY);
+@@ -876,9 +878,11 @@ QByteArray QXcbClipboard::clipboardReadIncrementalProperty(xcb_window_t win, xcb
+                 tmp_buf.resize(0);
+                 offset += length;
+             }
+-        } else {
+-            break;
+         }
++
++        const auto elapsed = timer.elapsed();
++        if (elapsed > clipboard_timeout)
++            break;
+     }
+ 
+     // timed out ... create a new requestor window, otherwise the requestor
+-- 
+2.16.3
+



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108140839.17E8d8GI083443>