mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibGfx: Redirect PNG errors and warnings to our own logging functions
Before, libpng would use its own internal logging mechanism to print non-fatal errors and warnings to stdout/stderr. This made it confusing when trying to search the Ladybird codebase for those messages as they didn't exist. This commit uses `png_set_error_fn` from libpng to redirect those messages to our own custom logging functions instead.
This commit is contained in:
parent
d835a00bee
commit
e4fb25bf63
Notes:
github-actions[bot]
2024-12-10 19:07:03 +00:00
Author: https://github.com/rmg-x Commit: https://github.com/LadybirdBrowser/ladybird/commit/e4fb25bf636 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2840 Reviewed-by: https://github.com/LucasChollet Reviewed-by: https://github.com/tcl3
1 changed files with 13 additions and 0 deletions
|
@ -82,6 +82,17 @@ ErrorOr<Optional<ReadonlyBytes>> PNGImageDecoderPlugin::icc_data()
|
|||
return OptionalNone {};
|
||||
}
|
||||
|
||||
static void log_png_error(png_structp png_ptr, char const* error_message)
|
||||
{
|
||||
dbgln("libpng error: {}", error_message);
|
||||
png_longjmp(png_ptr, 1);
|
||||
}
|
||||
|
||||
static void log_png_warning(png_structp, char const* warning_message)
|
||||
{
|
||||
dbgln("libpng warning: {}", warning_message);
|
||||
}
|
||||
|
||||
ErrorOr<void> PNGImageDecoderPlugin::initialize()
|
||||
{
|
||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
|
||||
|
@ -109,6 +120,8 @@ ErrorOr<void> PNGImageDecoderPlugin::initialize()
|
|||
*read_data = read_data->slice(length);
|
||||
});
|
||||
|
||||
png_set_error_fn(png_ptr, nullptr, log_png_error, log_png_warning);
|
||||
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
u32 width = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue