Crash when trying to add inline component in non-inline component



  • I think I've spotted a bug in QML. I have the following component:

    @
    import QtQuick 2.2
    Rectangle
    {
    id: root;
    default property alias contents: contentFrame.children;
    color: "#05f"; width: 100; height: 100;

    Rectangle
    {
        id: contentFrame;
        anchors
        {
            fill: parent;
            leftMargin: 10; topMargin: 10; rightMargin: 10; bottomMargin: 10;
        }
        color: "#888";
    }
    

    }
    @

    The above component is saved as Test1.qml in a resource file qml.qrc. Now I create another component Test2.qml that uses Test1:

    @
    import QtQuick 2.2

    Test1
    {
    id: root;

    Rectangle
    {
        id: contentFrame;
        anchors
        {
            // fill: root; // fails, because our parent is NOT root [A]
            fill: parent;  // this is NOT root, but Test1's default item!
            leftMargin: 10; topMargin: 10; rightMargin: 10; bottomMargin: 10;
        }
        color: "#0a0";
    }
    
    /* Component // CRASH if you uncomment this! [B]
    {
        id: separator;
        Rectangle
        {
            height: 1;
            color: "#fab";
        }
    } */
    

    }
    @

    I marked two lines in the code above: [A]: This is perfectly OK: As I changed the default property in Test1, the Rectangle's parent isn't root, but some other item in Test1 (contentFrame).

    [B]: This is weird and probably a bug! If you add the definition of some component inside a component whose default property has been changed, the app would immediately crash!

    Is this a known bug? I'm using Qt 5.3.0.



  • I just tested this with Qt 5.3.2, the problem persists, it would still crash.


  • Qt Champions 2017

    Yes, It crashes. Here we are trying to extend the external component again. This could be leading to the issue. However it not should not crash. May qml compiler should fix this issue. I suggest you can file a bug on this.




Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.