From bf314ba7017c4cb0a902726a049c7313b5e1f156 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 24 Aug 2013 15:32:35 -0400 Subject: Throw error if image file does not exist. --- 2d/texture.scm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to '2d') diff --git a/2d/texture.scm b/2d/texture.scm index b7808b3..19c26c8 100644 --- a/2d/texture.scm +++ b/2d/texture.scm @@ -132,7 +132,13 @@ 0 0 1 1))) (define (load-bitmap filename) - (let* ((bitmap (freeimage-load (freeimage-get-file-type filename) filename)) + ;; Throw an error if image file does not exist or else we will + ;; segfault later. + (unless (file-exists? filename) + (throw 'image-not-found filename)) + ;; Load image and convert it to 32 bit color. + (let* ((image-type (freeimage-get-file-type filename)) + (bitmap (freeimage-load image-type filename)) (32bit-bitmap (freeimage-convert-to-32-bits bitmap))) (freeimage-unload bitmap) 32bit-bitmap)) -- cgit v1.2.3