From f5f4ded789379c77575b6ea4ab9cde6589afd2dd Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 19 Jul 2015 11:59:38 -0500 Subject: [PATCH] add slow load handling for m3u files --- BizHawk.Client.Common/RomLoader.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/BizHawk.Client.Common/RomLoader.cs b/BizHawk.Client.Common/RomLoader.cs index ba7f0442b0..c5198cc317 100644 --- a/BizHawk.Client.Common/RomLoader.cs +++ b/BizHawk.Client.Common/RomLoader.cs @@ -256,10 +256,22 @@ namespace BizHawk.Client.Common { Disc disc = null; string discPath = e.Path; - string discExt = Path.GetExtension(discPath).ToLower(); - disc = Disc.LoadAutomagic(discPath); + + //--- load the disc in a context which will let us abort if it's going to take too long + var discMountJob = new DiscMountJob { IN_FromPath = discPath }; + discMountJob.IN_SlowLoadAbortThreshold = 8; + discMountJob.Run(); + disc = discMountJob.OUT_Disc; + + if (discMountJob.OUT_SlowLoadAborted) + { + System.Windows.Forms.MessageBox.Show("This disc would take too long to load. Run it through discohawk first, or find a new rip because this one is probably junk"); + return false; + } + if(disc == null) throw new InvalidOperationException("Can't load one of the files specified in the M3U"); + var discName = Path.GetFileNameWithoutExtension(discPath); discNames.Add(discName); discs.Add(disc);