Skip to content

Commit

Permalink
* fixed: MobiVM#778 -- Idea run dialog was not saving Sim details if …
Browse files Browse the repository at this point in the history
…no device is attached and selected in preferred device udid (MobiVM#779)

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

(cherry picked from commit 7080cc8)
  • Loading branch information
dkimitsa committed Apr 12, 2024
1 parent ab6d813 commit bb20281
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}

/**
Expand Down

0 comments on commit bb20281

Please sign in to comment.