From 4730ec4eb0f26003652fd812bb45ec82a0009c02 Mon Sep 17 00:00:00 2001 From: Rupert Date: Tue, 19 Nov 2024 01:37:19 +0100 Subject: [PATCH] plug-ins: avoid log-spamming by tiff plug-in * last log I checked had over 30.000 tiff msgs * limit tiff_io_warning() and tiff_io_error() to a max of 3 msgs --- plug-ins/file-tiff/file-tiff-io.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plug-ins/file-tiff/file-tiff-io.c b/plug-ins/file-tiff/file-tiff-io.c index 8e282a1e68..ac4f92530e 100644 --- a/plug-ins/file-tiff/file-tiff-io.c +++ b/plug-ins/file-tiff/file-tiff-io.c @@ -163,6 +163,8 @@ tiff_reset_file_size_error (void) tiff_file_size_error = FALSE; } +static gint max_msgs_per_instance = 3; + static void tiff_io_warning (const gchar *module, const gchar *fmt, @@ -170,6 +172,11 @@ tiff_io_warning (const gchar *module, { gint tag = 0; + if (max_msgs_per_instance > 0) + max_msgs_per_instance--; + else + return; + /* Between libtiff 3.7.0beta2 and 4.0.0alpha. */ if (! strcmp (fmt, "%s: unknown field with tag %d (0x%x) encountered") || /* Before libtiff 3.7.0beta2. */ @@ -280,6 +287,11 @@ tiff_io_error (const gchar *module, { gchar *msg; + if (max_msgs_per_instance > 0) + max_msgs_per_instance--; + else + return; + /* Workaround for: http://bugzilla.gnome.org/show_bug.cgi?id=132297 * Ignore the errors related to random access and JPEG compression */