From f9ba3b70263b06b3dd430e2430db4b5faea8b894 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Fri, 1 Jan 2016 21:27:10 +0000 Subject: Add checking of files git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@3157 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/base/UCovers.pas | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/base/UCovers.pas b/src/base/UCovers.pas index 6c7c9e48..7f378c40 100644 --- a/src/base/UCovers.pas +++ b/src/base/UCovers.pas @@ -154,7 +154,12 @@ begin end; function TCover.GetTexture(): TTexture; +var + debughelper: UTF8String; begin + if not (Assigned(Filename)) or (Filename = nil) then + Exit; + debughelper := Filename.ToUTF8(true); Result := Texture.LoadTexture(Filename); end; @@ -268,10 +273,18 @@ begin end; function TCoverDatabase.FindCoverIntern(const Filename: IPath): int64; +var + FileUTF8String: UTF8String; begin - Result := DB.GetTableValue('SELECT [ID] FROM ['+COVER_TBL+'] ' + + if Filename = nil then + Result := 0 + else + begin + FileUTF8String:=Filename.ToUTF8; + Result := DB.GetTableValue('SELECT [ID] FROM ['+COVER_TBL+'] ' + 'WHERE [Filename] = ?', - [Filename.ToUTF8]); + [FileUTF8String]); + end; end; function TCoverDatabase.FindCover(const Filename: IPath): TCover; @@ -315,7 +328,7 @@ begin FileDate := Now(); //FileDateToDateTime(FileAge(Filename)); Thumbnail := CreateThumbnail(Filename, Info); - if (Thumbnail = nil) then + if not (assigned(Thumbnail)) or (Thumbnail = nil) then Exit; CoverData := TBlobWrapper.Create; @@ -451,7 +464,7 @@ begin // TODO: do not scale if image is smaller ScaleImage(Thumbnail, MaxSize, MaxSize); - + Result := Thumbnail; end; -- cgit v1.2.3