[Bf-blender-cvs] [4bd3b02984b] master: Python: Suppress BGL deprecation messages after 100 times.
Jeroen Bakker
noreply at git.blender.org
Mon Feb 6 13:39:03 CET 2023
Commit: 4bd3b02984bba193e0fcd9455498f13134b9a7c8
Author: Jeroen Bakker
Date: Mon Feb 6 13:35:29 2023 +0100
Branches: master
https://developer.blender.org/rB4bd3b02984bba193e0fcd9455498f13134b9a7c8
Python: Suppress BGL deprecation messages after 100 times.
BGL deprecation calls used to be reported on each use. As bgl calls
are typically part of a handler that is triggered at refresh this
could lead to overflow of messages and slowing down systems when
the terminal/console had to be refreshed as well.
This patch only reports the first 100 bgl deprecation calls. This
gives enough feedback to the developer that changes needs to be made
. But still provides good responsiveness to users when they have
such add-on enabled. Only the first frames can have a slowdown.
===================================================================
M source/blender/python/generic/bgl.c
===================================================================
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index f62f427542d..4a5c68947c1 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -40,6 +40,12 @@ static CLG_LogRef LOG = {"bgl"};
static void report_deprecated_call(const char *function_name)
{
+ /* Only report first 100 deprecated calls. BGL is typically used inside an handler that is
+ * triggered at refresh. */
+ static int times = 0;
+ while (times >= 100) {
+ return;
+ }
char message[256];
SNPRINTF(message,
"'bgl.gl%s' is deprecated and will be removed in Blender 3.7. Report or update your "
@@ -47,6 +53,7 @@ static void report_deprecated_call(const char *function_name)
function_name);
CLOG_WARN(&LOG, "%s", message);
PyErr_WarnEx(PyExc_DeprecationWarning, message, 1);
+ times++;
}
static void report_deprecated_call_to_user(void)
More information about the Bf-blender-cvs
mailing list