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

QQmlDelayedError crash when calling positionViewAtEnd() on a ListView

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.11.0 Beta 4
    • 5.6.0
    • None
    • Windows Versions Used: Windows 10, 8.1
      QT Version: 5.6.0
      Seen in:
      * Visual Studio 2015 compiler MSVC2015 (32bit and 64bit)
      * Visual Studio 2013 compiler MSVC2013 (32bit and 64bit)

    Description

      Take the following files...

      main.qml

      import QtQuick 2.4
      import QtQuick.Layouts 1.0
      import QtQuick.Controls 1.4
      import QtQuick.Controls.Styles.Flat 1.0 as Flat
      import QtQuick.Extras 1.4
      import QtQuick.Extras.Private 1.0
      
      ApplicationWindow {
          id: window
          width: 480
          height: 860
          visible:true
      
          ColumnLayout{
              anchors.fill: parent
              Button {
                  Layout.fillWidth: true
                  text:"Press To Crash"
                  onClicked:{
                      var component;
                      var config;
                      component = Qt.createComponent("LargeFileWithError.qml");
                      config = component.createObject(window)
                  }
              }
      
              ListView {
                  id: listView
                  Layout.fillHeight: true
                  Layout.fillWidth: true
      
                  model:logMessages
                  delegate: Text{
                      text:display
                      font.pixelSize: 11
                  }
      
                  Connections{
                      target:logMessages
                      onDataChanged:{
                          listView.positionViewAtEnd(); // AutoScroll
                      }
                  }
              }
          }
      }
      

      LargeFileWithError.qml

      import QtQuick 2.0
      import QtQuick.Controls 1.4
      import QtQuick.Layouts 1.3
      
      Rectangle {
          anchors.fill: parent
      
          Flickable{
              anchors.fill: parent
              contentWidth: parent.width
              contentHeight: 4000
              ColumnLayout{
                  id:flickableLayout
                  anchors.fill: parent
                  spacing: 0
                  Repeater{
                      model:100
                      Slider{
                          // Value does not exist and should throw QML Error:
                          //      qrc:/LargeFileWithError.qml:16: ReferenceError: causeErrorValue is not defined
                          value:causeErrorValue
                      }
                  }
              }
          }
      }
      

      main.cpp

      #include <QtGui/QGuiApplication>
      #include <QtQml/QQmlApplicationEngine>
      #include <Windows.h>
      #include <QStringListModel>
      #include <QQmlContext>
      
      static void QTDDebugHandler(QtMsgType type, const QMessageLogContext &, const QString &sMsg);
      static QStringListModel s_testListModel;
      
      int main(int argc, char *argv[])
      {
          qInstallMessageHandler(QTDDebugHandler);
          QGuiApplication app(argc, argv);
          QQmlApplicationEngine engine;
          engine.rootContext()->setContextProperty("logMessages", &s_testListModel);
          engine.load(QUrl("qrc:/main.qml"));
          if (engine.rootObjects().isEmpty())
              return -1;
          return app.exec();
      }
      
      void QTDDebugHandler(QtMsgType type, const QMessageLogContext &, const QString &sMsg)
      {
          int iInsertRow = s_testListModel.rowCount();
          if (s_testListModel.insertRow(iInsertRow)) {
            s_testListModel.setData(s_testListModel.index(iInsertRow), sMsg);
          }
      
          OutputDebugStringA(sMsg.toLatin1().constData());
          OutputDebugStringA("\n");
      }
      

      When pressing the button "Press To Crash" the application will crash. The purpose is to generate a bunch of QML errors to be displayed. It seems to be a race condition, because the more QML errors that are occurring the more likely the crash will be to happen. In the example given, 100 QML errors should show up and the crash happens almost every time.

      The crash is occurring in qtdeclarative\src\qml\qml\qqmlcomponent.cpp line 921 because enginePriv->erroredBindings has changed to null.

      Attachments

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

        Activity

          People

            shausman Simon Hausmann
            seang Sean Gayner
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes