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.
This commit is contained in:
Jeroen Bakker 2023-02-06 13:35:29 +01:00
parent 7beb487e9a
commit 4bd3b02984
1 changed files with 7 additions and 0 deletions

View File

@ -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)