Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-73044

BadLength on clipboard copy/paste image

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 5.13.0
    • 5.6.3, 5.9.7, 5.11.3, 5.12.0
    • QPA: X11/XCB
    • None
    • Linux/X11
    • c0ebec51e3dd1b52767878fe7fd56ce6e8f95461 (qt/qtbase/dev)

      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();
      }

       

      1. First start the application "b.cpp"
      2. 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".

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            paeglis Gatis Paeglis
            zccrs JiDe Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes