LibGfx: Redirect PNG errors and warnings to our own logging functions
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
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