Skip to content

Commit

Permalink
Crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryMarkle committed Sep 10, 2024
1 parent b5cc213 commit cd57677
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions Leditor.Data/LevelState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ namespace Leditor.Data;
/// </summary>
public sealed class LevelState
{
/// <summary>
/// Owned and managed by the class
/// </summary>
public Image LightMap { get; private set; }

private (int left, int top, int right, int bottom) _padding;
Expand Down Expand Up @@ -72,7 +75,7 @@ MaterialDefinition defaultMaterial

~LevelState()
{
Raylib.UnloadImage(LightMap);
if (LightMap is not { Width: 0 } or { Height: 0 }) Raylib.UnloadImage(LightMap);
}

public void Import(
Expand Down Expand Up @@ -118,7 +121,10 @@ public void Import(
LightMode = lightMode;
DefaultTerrain = terrainMedium;

if (LightMap is not { Width: 0 } or { Height: 0 }) Raylib.UnloadImage(LightMap);
if (LightMap is not { Width: 0 } or { Height: 0 }) {
Raylib.UnloadImage(LightMap);
}

LightMap = lightmap;

LevelCreated?.Invoke();
Expand Down
2 changes: 1 addition & 1 deletion Leditor/Pages/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ public override void Draw()

EndTextureMode();

UnloadImage(result.LightMapImage);
// UnloadImage(result.LightMapImage);

UnloadTexture(lightMapTexture);

Expand Down
2 changes: 1 addition & 1 deletion Leditor/Pages/Start.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ public override void Draw()

EndTextureMode();

UnloadImage(result.LightMapImage);
// UnloadImage(result.LightMapImage);

UnloadTexture(lightMapTexture);

Expand Down
2 changes: 1 addition & 1 deletion Release_Notes.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Midigated the chances of the program crashing when loading levels with malformed props line.
- Fixed a crash when loading a second level.
2 changes: 1 addition & 1 deletion Version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.99-7
0.9.99-8

0 comments on commit cd57677

Please sign in to comment.