summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-11-13 00:25:27 +0000
committerAndreas Kling <kling@serenityos.org>2020-11-14 10:11:26 +0100
commit5b68ea8dde12a6ff6f77d22ddfd24ebe50147e8a (patch)
tree038f5520024b26c5212a9d9f9eea4b74dbebdde7
parentd3ee3fc68a67403940c22ad7ce20a9fb514e603f (diff)
downloadserenity-5b68ea8dde12a6ff6f77d22ddfd24ebe50147e8a.zip
LibGfx: Make Bitmap path handling case insensitive
Bitmap::is_path_a_supported_image_format() and Bitmap::load_from_file() now check the file extension with CaseSensitivity::CaseInsensitive. This fixes a couple of inconsistencies, for example would FileSystemModel::icon_for() recognize image files uppercase extensions but couldn't create thumbnails for them (any attempt to create a bitmap from such files would fail).
-rw-r--r--Libraries/LibGUI/FileSystemModel.cpp2
-rw-r--r--Libraries/LibGfx/Bitmap.cpp4
-rw-r--r--Libraries/LibGfx/Bitmap.h4
3 files changed, 5 insertions, 5 deletions
diff --git a/Libraries/LibGUI/FileSystemModel.cpp b/Libraries/LibGUI/FileSystemModel.cpp
index b132e8800a..de2ae8a404 100644
--- a/Libraries/LibGUI/FileSystemModel.cpp
+++ b/Libraries/LibGUI/FileSystemModel.cpp
@@ -471,7 +471,7 @@ Icon FileSystemModel::icon_for(const Node& node) const
if (node.full_path() == "/")
return FileIconProvider::icon_for_path("/");
- if (Gfx::Bitmap::is_path_a_supported_image_format(node.name.to_lowercase())) {
+ if (Gfx::Bitmap::is_path_a_supported_image_format(node.name)) {
if (!node.thumbnail) {
if (!const_cast<FileSystemModel*>(this)->fetch_thumbnail_for(node))
return FileIconProvider::filetype_image_icon();
diff --git a/Libraries/LibGfx/Bitmap.cpp b/Libraries/LibGfx/Bitmap.cpp
index cd07ce0037..cc102d45c0 100644
--- a/Libraries/LibGfx/Bitmap.cpp
+++ b/Libraries/LibGfx/Bitmap.cpp
@@ -122,8 +122,8 @@ RefPtr<Bitmap> Bitmap::create_wrapper(BitmapFormat format, const IntSize& size,
RefPtr<Bitmap> Bitmap::load_from_file(const StringView& path)
{
-#define __ENUMERATE_IMAGE_FORMAT(Name, Ext) \
- if (path.ends_with(Ext)) \
+#define __ENUMERATE_IMAGE_FORMAT(Name, Ext) \
+ if (path.ends_with(Ext, CaseSensitivity::CaseInsensitive)) \
return load_##Name(path);
ENUMERATE_IMAGE_FORMATS
#undef __ENUMERATE_IMAGE_FORMAT
diff --git a/Libraries/LibGfx/Bitmap.h b/Libraries/LibGfx/Bitmap.h
index 493c3292f6..c1118784d8 100644
--- a/Libraries/LibGfx/Bitmap.h
+++ b/Libraries/LibGfx/Bitmap.h
@@ -97,8 +97,8 @@ public:
static RefPtr<Bitmap> create_from_serialized_byte_buffer(ByteBuffer&& buffer);
static bool is_path_a_supported_image_format(const StringView& path)
{
-#define __ENUMERATE_IMAGE_FORMAT(Name, Ext) \
- if (path.ends_with(Ext)) \
+#define __ENUMERATE_IMAGE_FORMAT(Name, Ext) \
+ if (path.ends_with(Ext, CaseSensitivity::CaseInsensitive)) \
return true;
ENUMERATE_IMAGE_FORMATS
#undef __ENUMERATE_IMAGE_FORMAT