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

QQuickStylePlugin crashes when calling qmlClearTypeRegistrations

    XMLWordPrintable

Details

    • 9478053838ae2d950b162c2b93a2a400c82d9bf7

    Description

      Hello, I was trying to restart a qml application to apply a style change to quickcontrols2. Calling qmlClearTypeRegistrations results in a crash most of times:

      (gdb) backtrace
      #0  0x0000000000000045 in ?? ()
      #1  0x00007ffff7bc694b in QScopedPointerDeleter<QQuickProxyTheme>::cleanup (pointer=<optimized out>) at /usr/include/qt5/QtCore/qscopedpointer.h:52
      #2  QScopedPointer<QQuickProxyTheme, QScopedPointerDeleter<QQuickProxyTheme> >::~QScopedPointer (this=0x7fffbc02d1f8, __in_chrg=<optimized out>) at /usr/include/qt5/QtCore/qscopedpointer.h:107
      #3  QQuickStylePlugin::~QQuickStylePlugin (this=0x7fffbc02d1e0, __in_chrg=<optimized out>) at qquickstyleplugin.cpp:49
      #4  0x00007fffd6de3845 in QtQuickControls2Plugin::~QtQuickControls2Plugin (this=0x7fffbc02d1e0, __in_chrg=<optimized out>) at qtquickcontrols2plugin.cpp:95
      #5  QtQuickControls2Plugin::~QtQuickControls2Plugin (this=0x7fffbc02d1e0, __in_chrg=<optimized out>) at qtquickcontrols2plugin.cpp:96
      #6  0x00007ffff5736a66 in QLibraryPrivate::unload(QLibraryPrivate::UnloadFlag) () at /usr/include/c++/8/bits/atomic_base.h:390
      #7  0x00007ffff572b15b in QPluginLoader::unload (this=0x7fffbc001f40) at plugin/qpluginloader.cpp:263
      #8  0x00007ffff61e33e1 in ?? () from /usr/lib64/libQt5Qml.so.5
      #9  0x00007ffff61905b9 in qmlClearTypeRegistrations() () from /usr/lib64/libQt5Qml.so.5
      #10 0x000000000040116a in main (argc=1, argv=0x7fffffffdb68) at ../../StyleBug/main.cpp:10
      

      Example code:

      main.cpp
      #include <QApplication>
      #include <QQmlApplicationEngine>
      #include <QQuickStyle>
      
      int main(int argc, char *argv[])
      {
          int res;
          int style = -1;
          do {
              qmlClearTypeRegistrations();
              QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
      
              QApplication app(argc, argv);
      
              if (style != -1)
                  QQuickStyle::setStyle(QQuickStyle::availableStyles()[style]);
      
              QQmlApplicationEngine engine;
              engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
              if (engine.rootObjects().isEmpty())
                  return -1;
      
              res = app.exec();
              style += res;
          } while (res > 0);
          return res;
      }
      
      main.qml
      import QtQuick 2.9
      import QtQuick.Controls 2.2
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
          Button {
              text: "Change Style"
              onClicked: Qt.exit(1);
          }
      }
      

      Note that qmlClearTypeRegistrations() doesn't crash when changing from org.style.desktop to another style (or itself) and the application successfully restarts.

      Attachments

        1. qtbug69440.zip
          2 kB
          Mitch Curtis

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              raffarti Raffaele Pertile
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes