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

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

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

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

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes