Skip to content

com.codename1.ui.Component.preferredSizeImpl() is unsafe as it sets the preferredSize from calcPreferredSize() which may be overridden #1363

@ghost

Description

Original issue 1364 created by codenameone on 2015-02-19T14:27:12.000Z:

com.codename1.ui.Component.preferredSizeImpl() is unsafe as it sets the preferredSize from calcPreferredSize() which may be overridden.

This can be troublesome because on the other side getPreferredSize() returns a reference to the private member preferredSize. If it springs to mind to override calcPreferredSize() of a component and to return the result of getPreferredSize of another Component one can get very funny results which could easily drive one crazy.

Hence I suggest that within com.codename1.ui.Component.preferredSizeImpl() the result of calcPreferredSize() should better be transferred into the preferredSize member by using its com.codename1.ui.geom.Dimension.setWidth(int) and com.codename1.ui.geom.Dimension.setHeight(int) methods.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions