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

@ -62,6 +62,8 @@ namespace RHLauncher
} }
private void HandleSendEmailResponse(string response) private void HandleSendEmailResponse(string response)
{
Invoke((MethodInvoker)(() =>
{ {
switch (response) switch (response)
{ {
@ -103,21 +105,24 @@ namespace RHLauncher
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--;
Invoke((MethodInvoker)(() =>
{
TimerLabel.Text = $"({secondsLeft})"; TimerLabel.Text = $"({secondsLeft})";
// If the timer has finished counting down, stop the timer and enable the ResendEmailButton
if (secondsLeft == 0) if (secondsLeft == 0)
{ {
resendTimer.Stop(); resendTimer.Stop();
SendEmailButton.Enabled = true; SendEmailButton.Enabled = true;
TimerLabel.Text = ""; 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'">