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

The `moveToThread()` idiom doesn't work consistently with `QTcpServer/QTcpSocket/QWebSocketServer/QWebSocket`; Hence mark that method as `= delete`

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.13.0, 5.14.1
    • Network: Sockets
    • None
    • All

    Description

      After lots of painstaking months of efforts and workarounds, I found out that the `moveToThread()` idiom with `QTcpSocket` and `QWebSocketServer` doesn't work consistently across all the platforms. It may fail with Ubuntu at some time and with Mac at other times. In Windows, it's more stable, but depending on MinGW or MSVC, it crashes at undetermined places. 

      I have documented all my findings in this post: https://stackoverflow.com/a/60273596/514235

      In brief, I suggest below in the following class bodies:

      class QTcpServer / QTcpSocket / QWebSocketServer / QWebSocket : public QObject
      {
        Q_OBJECT
        ...
        // Create this object in a desired thread instead of moving at runtime
        private: void moveToThread (QThread*) = delete; // hiding `QObject::moveToThread()`
      };
      

      Attachments

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

        Activity

          People

            tpochep Timur Pocheptsov
            iammilind Milind Gandhi
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes