Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed problem in 3 Layouts where Dimension reused between calls to getPreferredSize and getScrollSize #2229

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CodenameOne/src/com/codename1/ui/layouts/BorderLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,13 @@ private void positionTopBottom(Component target, Component c, int right, int lef
c.setHeight(Math.min(targetHeight, c.getPreferredH())); //verify I want to use tge prefered size
}

private Dimension dim = new Dimension(0, 0);
// private Dimension dim = new Dimension(0, 0); //moved into getPreferredSize, otherwise the same dim instance can be used both as preferredSize and scrollSize which creates side effects when preferredSize is forced to (0,0) in setHidden(true)

/**
* {@inheritDoc}
*/
public Dimension getPreferredSize(Container parent) {
Dimension dim = new Dimension(0, 0);
dim.setWidth(0);
dim.setHeight(0);
Component east = getEast();
Expand Down
3 changes: 2 additions & 1 deletion CodenameOne/src/com/codename1/ui/layouts/BoxLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public void layoutContainer(Container parent) {
}
}

private Dimension dim = new Dimension(0, 0);
// private Dimension dim = new Dimension(0, 0); //moved into getPreferredSize, otherwise the same dim instance can be used both as preferredSize and scrollSize which creates side effects when preferredSize is forced to (0,0) in setHidden(true)

/**
* {@inheritDoc}
Expand All @@ -228,6 +228,7 @@ public Dimension getPreferredSize(Container parent) {
}
}
Style s = parent.getStyle();
Dimension dim = new Dimension(0, 0);
dim.setWidth(width + s.getHorizontalPadding());
dim.setHeight(height + s.getVerticalPadding());
return dim;
Expand Down
3 changes: 2 additions & 1 deletion CodenameOne/src/com/codename1/ui/layouts/FlowLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ private void moveComponents(Container target, int x, int y, int width, int heigh
}
}

private Dimension dim = new Dimension(0, 0);
// private Dimension dim = new Dimension(0, 0);//moved into getPreferredSize, otherwise the same dim instance can be used both as preferredSize and scrollSize which creates side effects when preferredSize is forced to (0,0) in setHidden(true)

/**
* {@inheritDoc}
Expand Down Expand Up @@ -322,6 +322,7 @@ public Dimension getPreferredSize(Container parent) {

width = Math.max(w, width);

Dimension dim = new Dimension(0, 0);
dim.setWidth(width + parent.getStyle().getPaddingLeftNoRTL()+ parent.getStyle().getPaddingRightNoRTL());
dim.setHeight(height + parent.getStyle().getPaddingTop()+ parent.getStyle().getPaddingBottom());
return dim;
Expand Down