diff options
author | Liang Qi <liang.qi@qt.io> | 2021-07-07 13:19:14 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-08-10 12:22:15 +0000 |
commit | 73fc1f93e8bea1c493ed16655ad6fd68ae270e38 (patch) | |
tree | d850ca47e5d398596fab13d636a7db7e3f80aa35 | |
parent | 1d8bcfbb55db23acd40338c9615211ce8070fde3 (diff) |
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.
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>
-rw-r--r-- | src/plugins/platforms/xcb/qxcbclipboard.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp index 725c0e4d51..a4940f1c49 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.cpp +++ b/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 |