Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.6.3, 5.9.7, 5.11.3, 5.12.0
-
None
-
-
c0ebec51e3dd1b52767878fe7fd56ce6e8f95461 (qt/qtbase/dev)
Description
Copy a big image to clipboard, I get an error message: "qt.qpa.xcb: QXcbConnection: XCB error: 16 (BadLength), sequence: 3233, resource id: 98566210, major code: 0 (Null), minor code: 0". The following code can reproduce this problem:
// a.cpp #include <QGuiApplication> #include <QImage> #include <QClipboard> int main(int argc, char *argv[]) { QGuiApplication a(argc, argv); QImage image(5000, 5000, QImage::Format_ARGB32); image.fill(Qt::red); a.clipboard()->setImage(image); return a.exec(); }
// b.cpp #include <QGuiApplication> #include <QImage> #include <QClipboard> int main(int argc, char *argv[]) { QGuiApplication a(argc, argv); QClipboard *b = a.clipboard(); QObject::connect(b, &QClipboard::dataChanged, [b] { const QMimeData *data = b->mimeData(); if (data->hasFormat("image/bmp")) { qDebug() << data->data("image/bmp"); } }); return a.exec(); }
- First start the application "b.cpp"
- Second start the applicatioin "a.cpp"
I get the error messages in "a.cpp":
qt.qpa.xcb: QXcbConnection: XCB error: 16 (BadLength), sequence: 512, resource id: 104857604, major code: 0 (Null), minor code: 0
I found that the QXcbClipboard code has the "maxSelectionIncr" function:
https://github.com/qt/qtbase/blob/dev/src/plugins/platforms/xcb/qxcbclipboard.cpp#L682
But, "m_increment" does not use it.
https://github.com/qt/qtbase/blob/dev/src/plugins/platforms/xcb/qxcbclipboard.cpp#L244
I guess this bug is caused here. And the method of request the maximum length of data in the gtk2 library(of XLib) is consistent with "maxSelectionIncr".