Fix bug related to collection modification during Application.Restart() on ChangePassword.

This commit is contained in:
Junior 2023-10-05 23:36:56 -03:00
parent 46b2b6f15d
commit d5ec712d0f
3 changed files with 26 additions and 15 deletions

View file

@ -63,7 +63,9 @@ namespace RHLauncher
private void HandleSendEmailResponse(string response) private void HandleSendEmailResponse(string response)
{ {
switch (response) Invoke((MethodInvoker)(() =>
{
switch (response)
{ {
case "EmailSent": case "EmailSent":
SendEmailButton.Enabled = false; SendEmailButton.Enabled = false;
@ -102,22 +104,25 @@ namespace RHLauncher
default: default:
MsgBoxForm.Show("Error:" + response, LocalizedStrings.Error); MsgBoxForm.Show("Error:" + response, LocalizedStrings.Error);
break; break;
} }
}));
} }
private void ResendTimer_Tick(object? sender, EventArgs e) private void ResendTimer_Tick(object? sender, EventArgs e)
{ {
// Decrement the secondsLeft variable and update the button text // Decrement the secondsLeft variable and update the button text
secondsLeft--; secondsLeft--;
TimerLabel.Text = $"({secondsLeft})"; Invoke((MethodInvoker)(() =>
// If the timer has finished counting down, stop the timer and enable the ResendEmailButton
if (secondsLeft == 0)
{ {
resendTimer.Stop(); TimerLabel.Text = $"({secondsLeft})";
SendEmailButton.Enabled = true;
TimerLabel.Text = ""; if (secondsLeft == 0)
} {
resendTimer.Stop();
SendEmailButton.Enabled = true;
TimerLabel.Text = "";
}
}));
} }
private async Task<string> VerifyCodeSendRequestAsync() private async Task<string> VerifyCodeSendRequestAsync()
@ -155,11 +160,12 @@ namespace RHLauncher
registryHandler = new RegistryHandler(); registryHandler = new RegistryHandler();
registryHandler.ClearPassword(); registryHandler.ClearPassword();
Invoke((MethodInvoker)(() => Close()));
Application.Restart(); Application.Restart();
} }
else else
{ {
Close(); Invoke((MethodInvoker)(() => Close()));
} }
} }

View file

@ -460,19 +460,24 @@ namespace RHLauncher
public void Logout() public void Logout()
{ {
LoginForm? loginForm = Application.OpenForms.OfType<LoginForm>().FirstOrDefault(); LoginForm loginForm = Application.OpenForms.OfType<LoginForm>().FirstOrDefault();
if (loginForm != null) if (loginForm != null)
{ {
// Close the current form before restarting
Close();
// Restart the application
Application.Restart(); Application.Restart();
} }
else else
{ {
LoginForm newLoginForm = new(); LoginForm newLoginForm = new LoginForm();
newLoginForm.Show(); newLoginForm.Show();
Close(); Close();
} }
} }
private async void UpdateCheckButton_Click(object sender, EventArgs e) private async void UpdateCheckButton_Click(object sender, EventArgs e)
{ {
HidePanels(); HidePanels();

View file

@ -19,8 +19,8 @@
<AssemblyName>Launcher</AssemblyName> <AssemblyName>Launcher</AssemblyName>
<Description>Rusty Hearts Launcher</Description> <Description>Rusty Hearts Launcher</Description>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<AssemblyVersion>1.0.2</AssemblyVersion> <AssemblyVersion>1.0.3</AssemblyVersion>
<FileVersion>1.0.2</FileVersion> <FileVersion>1.0.3</FileVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">