From f9fc93a7c4f16beaaa8f40da4d86e55f9a230b1b Mon Sep 17 00:00:00 2001 From: dkimitsa <demyan.kimitsa@gmail.com> Date: Sat, 6 Apr 2024 21:35:33 +0300 Subject: [PATCH] * fixed: #778 -- Idea run dialog was not saving Sim details if no device is attached and selected in preferred device udid exception: > java.lang.NullPointerException: Cannot read field "id" because the return value of "org.robovm.idea.running.RoboVmIOSRunConfigurationSettingsEditor$Decorator.from(javax.swing.JComboBox)" is null --- .../RoboVmIOSRunConfigurationSettingsEditor.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/idea/src/main/java/org/robovm/idea/running/RoboVmIOSRunConfigurationSettingsEditor.java b/plugins/idea/src/main/java/org/robovm/idea/running/RoboVmIOSRunConfigurationSettingsEditor.java index e6ae51750..38ef3fb07 100755 --- a/plugins/idea/src/main/java/org/robovm/idea/running/RoboVmIOSRunConfigurationSettingsEditor.java +++ b/plugins/idea/src/main/java/org/robovm/idea/running/RoboVmIOSRunConfigurationSettingsEditor.java @@ -30,7 +30,6 @@ import org.robovm.compiler.target.ios.ProvisioningProfile; import org.robovm.compiler.target.ios.SigningIdentity; import org.robovm.compiler.util.InfoPList; -import org.robovm.compiler.util.PList; import org.robovm.idea.RoboVmPlugin; import org.robovm.idea.running.RoboVmRunConfiguration.EntryType; import org.robovm.libimobiledevice.IDevice; @@ -194,7 +193,8 @@ protected void applyEditorTo(@NotNull RoboVmRunConfiguration config) throws Conf config.setSigningIdentity(Decorator.from(signingIdentity).id); config.setProvisioningProfileType(Decorator.from(provisioningProfile).entryType); config.setProvisioningProfile(Decorator.from(provisioningProfile).id); - config.setTargetDeviceUDID(Decorator.from(targetDeviceUDID).id); + // TargetDeviceUDID is optional + config.setTargetDeviceUDID(Decorator.idOrNullFrom(targetDeviceUDID)); // simulator related config.setSimulatorArch((CpuArch) simArch.getSelectedItem()); config.setSimulatorType(Decorator.from(simType).entryType); @@ -816,6 +816,15 @@ static <T> Decorator<T> from(JComboBox<? extends Decorator<T>> cb) { //noinspection unchecked return (Decorator<T>) cb.getSelectedItem(); } + + /** + * @return id from decorator if it presents + */ + static <T> String idOrNullFrom(JComboBox<? extends Decorator<T>> cb) { + //noinspection unchecked + Decorator<T> decorator = (Decorator<T>) cb.getSelectedItem(); + return decorator != null ? decorator.id : null; + } } /**