Attempt to fix NPE in ComboBox from EA reports

This commit is contained in:
Kirill Kirichenko
2018-05-25 10:17:41 +03:00
parent d14218348b
commit 9aeba86131
3 changed files with 20 additions and 7 deletions
@@ -397,7 +397,7 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border, ErrorB
Insets i = getInsets();
Dimension abSize = arrowButton.getPreferredSize();
if (isCompact(comboBox)) {
if (isCompact(comboBox) && size != null) {
JBInsets.removeFrom(size, padding); // don't count paddings in compact mode
}
@@ -405,8 +405,11 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border, ErrorB
int editorWidth = editorSize != null ? editorSize.width + i.left + padding.left + padding.right : 0;
editorWidth = Math.max(editorWidth, MINIMUM_WIDTH.get() + i.left);
int width = Math.max(editorWidth + abSize.width, size.width + padding.left);
int height = Math.max(Math.max(editorHeight, Math.max(abSize.height, size.height)),
int width = size != null ? size.width : 0;
int height = size != null ? size.height : 0;
width = Math.max(editorWidth + abSize.width, width + padding.left);
height = Math.max(Math.max(editorHeight, Math.max(abSize.height, height)),
(isCompact(comboBox) ? COMPACT_HEIGHT.get() : MINIMUM_HEIGHT.get()) + i.top + i.bottom);
return new Dimension(width, height);
@@ -84,8 +84,13 @@ public class MacIntelliJComboBoxUI extends DarculaComboBoxUI {
int editorWidth = editorSize != null ? editorSize.width + i.left + padding.left + padding.right : 0;
editorWidth = Math.max(editorWidth, MINIMUM_WIDTH.get() + i.left);
return new Dimension(Math.max(size.width + padding.left, editorWidth + iconWidth),
Math.max(Math.max(iconHeight, size.height), editorHeight));
int width = size != null ? size.width : 0;
int height = size != null ? size.height : 0;
width = Math.max(width + padding.left, editorWidth + iconWidth);
height = Math.max(Math.max(iconHeight, height), editorHeight);
return new Dimension(width, height);
}
@Override
@@ -447,8 +447,13 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
int editorWidth = editorSize != null ? editorSize.width + i.left + padding.left + padding.right : 0;
editorWidth = Math.max(editorWidth, MINIMUM_WIDTH.get() + i.left);
return new Dimension(Math.max(editorWidth + ARROW_BUTTON_SIZE.width, size.width + padding.left),
Math.max(ARROW_BUTTON_SIZE.height, Math.max(editorHeight, size.height)));
int width = size != null ? size.width : 0;
int height = size != null ? size.height : 0;
width = Math.max(editorWidth + ARROW_BUTTON_SIZE.width, width + padding.left);
height = Math.max(ARROW_BUTTON_SIZE.height, Math.max(editorHeight, height));
return new Dimension(width, height);
}
@Override