mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-04-09 09:26:29 +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];
|
||||
NSLog(@"Using custom host: %@", self.hostTextField.text);
|
||||
}
|
||||
|
||||
if (![self validatePcSelected]) {
|
||||
NSLog(@"No valid PC selected");
|
||||
return;
|
||||
}
|
||||
|
||||
[CryptoManager generateKeyPairUsingSSl];
|
||||
NSString* uniqueId = [CryptoManager getUniqueID];
|
||||
NSData* cert = [CryptoManager readCertFromFile];
|
||||
@@ -74,6 +80,12 @@ static StreamConfiguration* streamConfig;
|
||||
_selectedHost = [[Computer alloc] initWithIp:self.hostTextField.text];
|
||||
NSLog(@"Using custom host: %@", self.hostTextField.text);
|
||||
}
|
||||
|
||||
if (![self validatePcSelected]) {
|
||||
NSLog(@"No valid PC selected");
|
||||
return;
|
||||
}
|
||||
|
||||
streamConfig = [[StreamConfiguration alloc] init];
|
||||
streamConfig.host = _selectedHost.hostName;
|
||||
streamConfig.hostAddr = [Utils resolveHost:_selectedHost.hostName];
|
||||
@@ -195,6 +207,19 @@ static StreamConfiguration* streamConfig;
|
||||
[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
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
|
||||
Reference in New Issue
Block a user