mikaelgrev/miglayout

Statement is always true

dbmalkovsky opened this issue · 2 comments

In net.miginfocom.layout.Grid in the Core module starting at line 226 the code is:

if (cx >= 0 && cy >= 0) {
	if (cy >= 0) {
		cellXY[0] = cx;
		cellXY[1] = cy;
	} else {    // Only one coordinate is specified. Use the current row (flowx) or column (flowy) to fill in.
		if (lc.isFlowX()) {
			cellXY[0] = cx;
		} else {
			cellXY[1] = cx;
		}
	}
	ensureIndexSizes(cx, cy);
}

The then body is reached if cx and cy are greater than or equal to zero. The next test if (cy >= 0) has to always be true doesn't it? Therefore redundant and the else is never executed.

You are absolutely correct. Good catch!
Row 227 should be "or", not "and"

Fixed with this commit: bba8828