Skip to content

Commit

Permalink
Fixed aggressive trimming, causing JSON file to not load when adding …
Browse files Browse the repository at this point in the history
…a SoundFont to the list
  • Loading branch information
KaleidonKep99 committed Feb 28, 2025
1 parent 05edcf5 commit 0b33c0b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions OmniConverter/Extensions/SoundFonts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class SoundFont : INotifyPropertyChanged
[JsonProperty]
public bool NoRampIn { get; private set; }

[JsonIgnore]
public string SoundFontDisplayName => $"{(Enabled ? "" : "[OFF] ")}{SoundFontPath}";

public SoundFont()
Expand Down
2 changes: 1 addition & 1 deletion OmniConverter/OmniConverter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<PublishSingleFile>true</PublishSingleFile>
<PublishTrimmed>true</PublishTrimmed>
<TrimMode>link</TrimMode>
<TrimMode>partial</TrimMode>
<OutputType>WinExe</OutputType>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
Expand Down
10 changes: 6 additions & 4 deletions OmniConverter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ namespace OmniConverter
internal class Program
{
public static readonly string tempConvFile = "omniconv.temp";
public static readonly string tempConvFilePath = AppContext.BaseDirectory + $"/{tempConvFile}";
private static readonly string settingsPath = AppContext.BaseDirectory + "/settings.json";
public static readonly string tempConvFilePath = $"{AppDomain.CurrentDomain.BaseDirectory}/{tempConvFile}";
private static readonly string settingsPath = $"{AppDomain.CurrentDomain.BaseDirectory}/settings.json";

public static Settings Settings { get; private set; } = new();
public static SoundFonts SoundFontsManager { get; private set; } = new();
public static bool FFmpegAvailable { get; private set; } = false;
Expand Down Expand Up @@ -111,7 +112,7 @@ public static void LoadConfig(bool startup = false)
using (StreamReader sr = new(settingsPath))
settingsJSON = sr.ReadToEnd();

var jsonSettings = new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Ignore };
var jsonSettings = new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Ignore, NullValueHandling = NullValueHandling.Ignore };
var userSettings = JsonConvert.DeserializeObject<Settings?>(settingsJSON, jsonSettings);

if (userSettings == null)
Expand All @@ -122,8 +123,9 @@ public static void LoadConfig(bool startup = false)

Settings = userSettings;
}
catch
catch (Exception ex)
{
Debug.PrintToConsole(Debug.LogType.Warning, $"Something went wrong while opening the file! {ex.Message}");
CreateConfig(startup);
}
finally
Expand Down

0 comments on commit 0b33c0b

Please sign in to comment.