mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-17 14:11:35 +00:00
Don't crash if no PC is selected when a button is pressed
This commit is contained in:
@@ -34,6 +34,12 @@ static StreamConfiguration* streamConfig;
|
|||||||
_selectedHost = [[Computer alloc] initWithIp:self.hostTextField.text];
|
_selectedHost = [[Computer alloc] initWithIp:self.hostTextField.text];
|
||||||
NSLog(@"Using custom host: %@", self.hostTextField.text);
|
NSLog(@"Using custom host: %@", self.hostTextField.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (![self validatePcSelected]) {
|
||||||
|
NSLog(@"No valid PC selected");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
[CryptoManager generateKeyPairUsingSSl];
|
[CryptoManager generateKeyPairUsingSSl];
|
||||||
NSString* uniqueId = [CryptoManager getUniqueID];
|
NSString* uniqueId = [CryptoManager getUniqueID];
|
||||||
NSData* cert = [CryptoManager readCertFromFile];
|
NSData* cert = [CryptoManager readCertFromFile];
|
||||||
@@ -74,6 +80,12 @@ static StreamConfiguration* streamConfig;
|
|||||||
_selectedHost = [[Computer alloc] initWithIp:self.hostTextField.text];
|
_selectedHost = [[Computer alloc] initWithIp:self.hostTextField.text];
|
||||||
NSLog(@"Using custom host: %@", self.hostTextField.text);
|
NSLog(@"Using custom host: %@", self.hostTextField.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (![self validatePcSelected]) {
|
||||||
|
NSLog(@"No valid PC selected");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
streamConfig = [[StreamConfiguration alloc] init];
|
streamConfig = [[StreamConfiguration alloc] init];
|
||||||
streamConfig.host = _selectedHost.hostName;
|
streamConfig.host = _selectedHost.hostName;
|
||||||
streamConfig.hostAddr = [Utils resolveHost:_selectedHost.hostName];
|
streamConfig.hostAddr = [Utils resolveHost:_selectedHost.hostName];
|
||||||
@@ -195,6 +207,19 @@ static StreamConfiguration* streamConfig;
|
|||||||
[self setSelectedHost:[self.HostPicker selectedRowInComponent:0]];
|
[self setSelectedHost:[self.HostPicker selectedRowInComponent:0]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)validatePcSelected {
|
||||||
|
if (_selectedHost == NULL) {
|
||||||
|
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"No PC Selected"
|
||||||
|
message:@"You must select a PC to continue."
|
||||||
|
preferredStyle:UIAlertControllerStyleAlert];
|
||||||
|
[alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:nil]];
|
||||||
|
[self presentViewController:alert animated:YES completion:nil];
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)didReceiveMemoryWarning
|
- (void)didReceiveMemoryWarning
|
||||||
{
|
{
|
||||||
[super didReceiveMemoryWarning];
|
[super didReceiveMemoryWarning];
|
||||||
|
|||||||
Reference in New Issue
Block a user