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

Revert the using of QThread::isMainThread() in qpixmap.cpp

XMLWordPrintable

    • Windows

      The commit is:
      https://codereview.qt-project.org/c/qt/qtbase/+/627786
      It replaces some if conditions using "QThread::isMainThread()". But under corner case, this causes crash.

      Minimal reproducer:

      #include <QApplication>
      #include <QThread>
      
      int main(int argc, char** argv)
      {
          std::thread([&]() {
              QApplication app(argc, argv);
          }).join();
      
          QApplication app(argc, argv);
      }
      

      The first QApplication in another thread is totally fine. But after that, during the initialization of the second QApplication, QThread gets confused:

      !QThread::isMainThread() 
      

      is somehow considered true, and if statement reaches

              && !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps)) {
      
      

      And it crashes there due to "platformIntegration()" returning nullptr;

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

            axelspoerl Axel Spoerl
            luqiaochen Luqiao Chen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes