From 92fa1efc760992eb6c011362d30031f6d86bd401 Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Sun, 9 Jul 2023 01:05:29 -0400 Subject: [PATCH] LibGfx/TGA: Decode the header in `create()` and remove `initialize()` This is done as a part of #19893. --- Userland/Libraries/LibGfx/ImageFormats/TGALoader.cpp | 9 +++------ Userland/Libraries/LibGfx/ImageFormats/TGALoader.h | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/TGALoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/TGALoader.cpp index d194b703bc..9a0ba2e7f8 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/TGALoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/TGALoader.cpp @@ -205,11 +205,6 @@ ErrorOr TGAImageDecoderPlugin::decode_tga_header() return {}; } -ErrorOr TGAImageDecoderPlugin::initialize() -{ - return decode_tga_header(); -} - ErrorOr TGAImageDecoderPlugin::validate_before_create(ReadonlyBytes data) { if (data.size() < sizeof(TGAHeader)) @@ -225,7 +220,9 @@ ErrorOr TGAImageDecoderPlugin::validate_before_create(ReadonlyBytes data) ErrorOr> TGAImageDecoderPlugin::create(ReadonlyBytes data) { - return adopt_nonnull_own_or_enomem(new (nothrow) TGAImageDecoderPlugin(data.data(), data.size())); + auto plugin = TRY(adopt_nonnull_own_or_enomem(new (nothrow) TGAImageDecoderPlugin(data.data(), data.size()))); + TRY(plugin->decode_tga_header()); + return plugin; } bool TGAImageDecoderPlugin::is_animated() diff --git a/Userland/Libraries/LibGfx/ImageFormats/TGALoader.h b/Userland/Libraries/LibGfx/ImageFormats/TGALoader.h index 472016fe4f..6deef25762 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/TGALoader.h +++ b/Userland/Libraries/LibGfx/ImageFormats/TGALoader.h @@ -22,7 +22,6 @@ public: virtual IntSize size() override; - virtual ErrorOr initialize() override; virtual bool is_animated() override; virtual size_t loop_count() override; virtual size_t frame_count() override;