diff --git a/Vocaluxe/Base/CCover.cs b/Vocaluxe/Base/CCover.cs index ac9cc10c..24e25e3e 100644 --- a/Vocaluxe/Base/CCover.cs +++ b/Vocaluxe/Base/CCover.cs @@ -177,62 +177,29 @@ namespace Vocaluxe.Base if (String.IsNullOrEmpty(coverTheme.Name)) return; - var ignoreList = new List(); - string coverPath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.Folder); List files = CHelper.ListImageFiles(coverPath, true, true); - CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.File)); lock (_Covers) { - if (xmlReader != null) - { - _Covers.Clear(); - List cover = xmlReader.GetNames("//root/Cover/*"); - foreach (string coverName in cover) - { - string name; - string filePath; - xmlReader.GetValue("//root/Cover/" + coverName + "/Name", out name, String.Empty); - xmlReader.GetValue("//root/Cover/" + coverName + "/Path", out filePath, String.Empty); - string coverFilePath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.Folder, filePath); - if (!File.Exists(coverFilePath)) - continue; - - _AddCover(name, coverFilePath); - ignoreList.Add(Path.GetFileName(coverFilePath)); - - if (name == "NoCover") - NoCover = _Covers[name]; - } - } - - foreach (string file in files) - { - if (!ignoreList.Contains(Path.GetFileName(file))) - _AddCover(Path.GetFileNameWithoutExtension(file), file); - } + _AddCover(Path.GetFileNameWithoutExtension(file), file); + if (_CoverExists("No Cover")) + NoCover = _Covers["No Cover"]; } } /// /// Ads a cover with the given name if it does not exist yet - /// MUST HOLD _Covers lock at this point /// /// Name of the cover /// Filename of image file private static void _AddCover(string name, string file) { - CTexture texture = CDraw.AddTexture(file); - - if (!_CoverExists(name)) - _Covers.Add(name, texture); - else + lock (_Covers) { - CTexture tex = _Covers[name]; - CDraw.RemoveTexture(ref tex); - _Covers[name] = texture; + if (!_CoverExists(name)) + _Covers.Add(name, CDraw.AddTexture(file)); } } }