Skip to content

layouting constraints not respected for items in if or for #407

@tronical

Description

@tronical

Edit: The panic is fixed, but the remaining bug is that element in if or for don't propagate their layout constraint to the parent when not in a layout.

That is:

    Flickable {
            HorizontalLayout { Rectangle { height: 55px; } }
    }  

Works, but

    Flickable {
            if true: HorizontalLayout { Rectangle { height: 55px; } }
    }  

Doesn't work as the geometry of the child is not used

Workaround: use a layout: #407 (comment)

The Slint code, tests, and docs reference this issue (git grep #407 to find them)
Notably, the fix should be around there:

// FIXME: we should ideally add runtime code to merge layout info of all elements that are repeated (same as #407)


Original issue:

The following minimal test-case causes a panic in the compiler in the generators/interpreter:

export Testcase := Window {
    preferred-width: 640px;
    preferred-height: 480px;
    Flickable {
            for blah in 1: HorizontalLayout {}
    }      
}

A call to unwrap() at the end of access_member panics:

  access_member(
            element,
            name,
            &component
                .parent_element
                .upgrade()
                .unwrap() // <-- this panics
                .borrow()
                .enclosing_component
                .upgrade()
                .unwrap(),
            quote!(#component_rust.parent.upgrade().unwrap().as_pin_ref()),
            is_special,
  )

Edit: Panic was fixed, but the layouting info of the inner repeated elements are not taken into account when they should
See FIXME in tests/cases/layout/issue_407_for_layout_in_flickable.60

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:compilerSlint compiler internal (not the codegen, not the parser)a:layoutsRelated to the layouting and positioning of the elements (mO,bT)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions