Qt World Summit: Register Today!

Problem with QClipboard

  • Hi,

    We have some clipboard problem with another desktop application (let's call it application B for now). Our product crashes when we copy something in B with almost random stacks.

    Our product has a slot connected the signal QClipboard::dataChanged(), here is what the slot does:
    void QtClipboard2::slotDataChanged()
    QClipboard* qclip = QApplication::clipboard();
    assert( qclip != NULL );
    const QMimeData* qmime = qclip->mimeData();
    QStringList qmime_types = qmime->formats();

    // also does some other stuff, but not related to the crash

    If I disconnect the signal and slot, no crash would happen. What bothers me is that we are not doing anything special about the MIME data or the clipboard. The only thing I have noticed interesting is that one copy action in application B will make Qt send the dataChange signal four times, whereas with other application (like Word, Outlook, paint, chrome), the slot is only called once . I don't have enough expertise to tell whether it is a problem or not, any idea here?

    Also to narrow down the problem, I made a much simpler Qt standalone which has only one QDialog with QTextEdit in it. The dialog has the same slot as QtClipboard2::slotDataChanged() connected to QClipboard::dataChanged signal. I cannot reproduce the crash with the sandalone, but the Visual Studio will break at
    OleGetClipboard(&pDataObj) in qclipboard_win.cpp always the second time the slot is called, with the following message

    "HEAP[Clipboard.exe]: Heap block at 0000000000440AD0 modified at 0000000000440AE0 past requested size of 0
    Windows has triggered a breakpoint in Clipboard.exe.

    This may be due to a corruption of the heap, which indicates a bug in Clipboard.exe or any of the DLLs it has loaded.

    This may also be due to the user pressing F12 while Clipboard.exe has focus.

    The output window may have more diagnostic information."

    Could that be related to the crash in our product? If it is, then it looks like it has nothing to do with us, but some problem between Qt and application B. Is there anything we can do to workaround the problem?

    Appreciate any help.


  • Lifetime Qt Champion


    That's pretty strange indeed. Did you took a look at the "bug report system":http://bugreports.qt-project.org to see if it's something known ?

  • Thanks SGaist for suggestion, I will check the bug report system.


  • Unfortunately, I cannot find any related bugs :(

    But something interesting I just found out. I can reproduce the crash on other Adobe Air based applications (application B is also based on Adobe Air). So now I am wondering whether this is a problem between Qt and Adobe Air. The copy action in the Adobe Air based applications (at least all the three I tried) will send out at least two dataChanged signal, the first one is always empty, we cannot get any MIME data from it. The rest will have the MIME data, but identical. Feels like Qt might have some problem with the way Adobe Air post clipboard changes.

    Also copying items in any of the three Adode Air based application triggers the heap corruption warning in Visual Studio with my standalone example.

    I will file a bug for it


  • Check https://bugreports.qt.io/browse/QTBUG-41329
    (I'm hitting the same problem)

Log in to reply