Fix crash in GC titles when right-clicking island acres

This commit is contained in:
Cuyler36 2019-01-14 16:20:14 -05:00
parent 6964903198
commit dae486c60d
4 changed files with 41 additions and 5 deletions

View file

@ -125,6 +125,8 @@
</Compile>
<Compile Include="ItemColorSettings.Designer.cs">
<DependentUpon>ItemColorSettings.settings</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="SecureValueForm\SecureValueForm.cs">
<SubType>Form</SubType>
@ -1411,6 +1413,9 @@
<Content Include="Resources\DBNM_Plus_Items_en.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\DNM_Acres_en.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\DnM_Items_en.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

View file

@ -8,11 +8,11 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace ACSE {
namespace ACSE.WinForms {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.0.0")]
internal sealed partial class ItemColorSettings : global::System.Configuration.ApplicationSettingsBase {
private static ItemColorSettings defaultInstance = ((ItemColorSettings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new ItemColorSettings())));

View file

@ -3196,9 +3196,16 @@ private void AcreClick(object sender, MouseEventArgs e, bool island = false)
}
else
{
var boxes = island ? (IList<PictureBoxWithInterpolationMode>) _islandItemEditors : _acreMap;
AcreImageManager.CheckReferencesAndDispose(oldImage, boxes,
_selectedAcrePicturebox);
if (island)
{
AcreImageManager.CheckReferencesAndDispose(oldImage, _islandItemEditors,
_selectedAcrePicturebox);
}
else
{
AcreImageManager.CheckReferencesAndDispose(oldImage, _acreMap,
_selectedAcrePicturebox);
}
}
_selectedAcreId = island ? IslandAcres[acreIndex].AcreId : _acres[acreIndex].AcreId;

View file

@ -160,6 +160,30 @@ public static void CheckReferencesAndDispose(Image referencedImage,
referencedImage.Dispose();
}
public static void CheckReferencesAndDispose(Image referencedImage,
IList<AcreItemEditor> itemEditors, PictureBoxWithInterpolationMode selectedAcreBox)
{
if (referencedImage == null || selectedAcreBox.Image == referencedImage
|| itemEditors.Any(
box => box != null && box.BackgroundImage == referencedImage)) return;
foreach (var pair in _loadedImageDictionary)
if (pair.Value == referencedImage)
{
_loadedImageDictionary.Remove(pair.Key);
break;
}
foreach (var pair in _loadedAnimalCrossingMapIcons)
if (pair.Value == referencedImage)
{
_loadedAnimalCrossingMapIcons.Remove(pair.Key);
break;
}
referencedImage.Dispose();
}
public static void DisposeLoadedImages()
{
foreach (var i in _loadedImageDictionary.Values)