- while(slack > 0) {
- // FEATURE: inefficient
- int startslack = slack;
- int increment = max(1, slack / cols);
- for(int col=0; col < cols && slack > 0; col++) {
- slack += colWidth[col];
- colWidth[col] = min(colMaxWidth[col], colWidth[col] + increment);
- slack -= colWidth[col];
- }
- if (slack == startslack) break;
- }
+ if (numChildren() > 0)
+ while(slack > 0) {
+ // FEATURE: inefficient
+ int startslack = slack;
+ int increment = max(1, slack / (cols == 0 ? (getChild(numChildren() - 1).col + 1) : cols));
+ for(int col=0; col < (cols == 0 ? (getChild(numChildren() - 1).col + 1) : cols) && slack > 0; col++) {
+ slack += colWidth[col];
+ colWidth[col] = min(colMaxWidth[col], colWidth[col] + increment);
+ slack -= colWidth[col];
+ }
+ if (slack == startslack) break;
+ }