mirror of
https://github.com/FroggMaster/CreamInstaller.git
synced 2026-06-12 11:01:23 -07:00
Fix: Rare Potential Crash/Null Reference
- Fixes a rare issue where the application could crash if the same window was called by multiple parts of the program at the same time. This could cause unexpected errors or crashes.
This commit is contained in:
@@ -9,6 +9,7 @@ namespace CreamInstaller.Forms;
|
||||
internal sealed partial class DebugForm : CustomForm
|
||||
{
|
||||
private static DebugForm current;
|
||||
private static readonly object currentLock = new();
|
||||
|
||||
private Form attachedForm;
|
||||
|
||||
@@ -22,9 +23,14 @@ internal sealed partial class DebugForm : CustomForm
|
||||
{
|
||||
get
|
||||
{
|
||||
if (current is not null && (current.Disposing || current.IsDisposed))
|
||||
current = null;
|
||||
return current ??= new();
|
||||
lock (currentLock)
|
||||
{
|
||||
if (current is null || current.Disposing || current.IsDisposed)
|
||||
{
|
||||
current = new DebugForm();
|
||||
}
|
||||
return current;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ internal sealed partial class SelectForm : CustomForm
|
||||
private const string HelpButtonListPrefix = "\n • ";
|
||||
|
||||
private static SelectForm current;
|
||||
private static readonly object currentLock = new();
|
||||
|
||||
private readonly ConcurrentDictionary<string, string> remainingDLCs = new();
|
||||
|
||||
@@ -43,9 +44,14 @@ internal sealed partial class SelectForm : CustomForm
|
||||
{
|
||||
get
|
||||
{
|
||||
if (current is not null && (current.Disposing || current.IsDisposed))
|
||||
current = null;
|
||||
return current ??= new();
|
||||
lock (currentLock)
|
||||
{
|
||||
if (current is null || current.Disposing || current.IsDisposed)
|
||||
{
|
||||
current = new SelectForm();
|
||||
}
|
||||
return current;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user