fix threading bug in movie scanner

This commit is contained in:
zeromus 2015-08-05 16:37:17 -05:00
parent 3ec314d20b
commit a283b2d1b9
1 changed files with 19 additions and 18 deletions
BizHawk.Client.EmuHawk/movie

View File

@ -87,26 +87,27 @@ namespace BizHawk.Client.EmuHawk
return null;
}
var index = IsDuplicateOf(filename);
if (!index.HasValue)
//System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start();
var movie = PreLoadMovieFile(file, force);
if (movie == null)
{
//System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start();
var movie = PreLoadMovieFile(file, force);
if (movie == null)
{
return null;
}
//watch.Stop(); Console.WriteLine("[{0}] {1}",watch.ElapsedMilliseconds,Path.GetFileName(filename));
lock (_movieList)
{
_movieList.Add(movie);
index = _movieList.Count - 1;
}
_sortReverse = false;
_sortedCol = string.Empty;
return null;
}
//watch.Stop(); Console.WriteLine("[{0}] {1}",watch.ElapsedMilliseconds,Path.GetFileName(filename));
int? index;
lock (_movieList)
{
//need to check IsDuplicateOf within the lock
index = IsDuplicateOf(filename);
if (index.HasValue) return index;
_movieList.Add(movie);
index = _movieList.Count - 1;
}
_sortReverse = false;
_sortedCol = string.Empty;
return index;
}