From 080489167bc511fe5be4325cde1939db5dc1a5d8 Mon Sep 17 00:00:00 2001
From: sr55 <sr55.hb@outlook.com>
Date: Sat, 7 Jan 2017 20:24:07 +0000
Subject: [PATCH] WinGui: Workaround a bug in libhb where if the audio track
 name == "", the engine crashes when initially writing the mp4 file.

---
 win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs
index 31f315f7e..a53996b0f 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs
@@ -14,6 +14,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
     using System.Globalization;
     using System.Linq;
     using System.Runtime.InteropServices;
+    using System.Runtime.InteropServices.ComTypes;
 
     using HandBrake.ApplicationServices.Interop;
     using HandBrake.ApplicationServices.Interop.HbLib;
@@ -360,7 +361,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
                     Mixdown = mixdown != null ? mixdown.Id : -1,
                     NormalizeMixLevel = false,
                     Samplerate = sampleRate != null ? sampleRate.Rate : 0,
-                    Name = item.TrackName,
+                    Name = !string.IsNullOrEmpty(item.TrackName) ? item.TrackName : null,
                 };
 
                 if (!item.IsPassthru)
-- 
2.40.0