Browse Source

Menu: Safely check type of 'checkIconFactory' factory property

As the type can only mismatch when darklaf is being uninstalled we don't care what happens in this case. Simply don't crash. Moreover this only happens on windows where the window decorations may change the component hierarchy during uninstallation to return the menu bar to the root pane.
Currently we don't make use of this property at all, but to keep the implementation close to the swing internal one we keep the method for now.
Relates to #234
jxlayer
weisj 3 years ago
parent
commit
4382249baf
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 7
      core/src/main/java/com/intellij/util/ui/MenuItemLayoutHelper.java

7
core/src/main/java/com/intellij/util/ui/MenuItemLayoutHelper.java

@ -45,6 +45,8 @@ import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.text.View;
import com.github.weisj.darklaf.util.Types;
@SuppressWarnings("unused")
public class MenuItemLayoutHelper {
public static final StringUIClientPropertyKey MAX_ARROW_WIDTH = new StringUIClientPropertyKey("maxArrowWidth");
@ -177,13 +179,12 @@ public class MenuItemLayoutHelper {
private Icon getIcon(String propertyPrefix) {
Icon icon = null;
MenuItemCheckIconFactory iconFactory =
(MenuItemCheckIconFactory) UIManager.get(propertyPrefix + ".checkIconFactory");
MenuItemCheckIconFactory iconFactory = Types.safeCast(
UIManager.get(propertyPrefix + ".checkIconFactory"), MenuItemCheckIconFactory.class);
if (!this.isColumnLayout || !this.useCheckAndArrow || iconFactory == null
|| !iconFactory.isCompatible(this.checkIcon, propertyPrefix)) {
icon = this.mi.getIcon();
}
return icon;
}

Loading…
Cancel
Save