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

CLONE - CLONE - Potential race condition in clipboard paste & drop code

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 6.4, 6.5
    • None
    • WebAssembly
    • Unintentionally cloned

    Description

      There's a potential race condition in the code that handles clipboard paste and drag & drop drop.

      Since the file reading operation from the FileTransfer object is asynchronous, if another drop or paste event arrives while the read operation is ongoing, the previous read should be canceled. Otherwise, its finalize callback will finalize the previous drop / paste operation.

      Consider:

      QWasmCompositor::initEventHandlers:

      screen()->element().call<void>("addEventListener", std::string("drop"),                                   val::module_property("qtDrop"), val(true));
      

      The qtDrop function is in fact in qwasmdrag.cpp: 
       

      static void dropEvent(val event)

       
      All of the event["dataTransfer"]["items"] are handled asynchronously. Assume event1 comes first. Then the 
      event["dataTransfer"]["items"] will be fetched async. In the meantime, event2 arrives. Another round of async fetches is started. Since we don't cancel the event1's fetches, they eventually finish and call QWasmDrag::qWasmDrop. The m_mimeData->clear() is called and event2 never has a chance to finalize, unless it has not loaded its first file. This is because of:

      if (thisDrag->m_mimeTypesCount != thisDrag->m_mimeData->formats().size()) return;

       

      Attachments

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

        Activity

          People

            mikolaj.boc Mikołaj Boc (Inactive)
            wschenke Winfried Schenke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes