From 623df5565386d2af963d9147deca231dd66bca16 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 14 Apr 2025 10:08:18 -0600 Subject: [PATCH] make DEBUG_THREADED_SIGNALS use a little more efficient at runtime --- libs/gtkmm2ext/gtk_ui.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc index db2374b211..24b3ede59d 100644 --- a/libs/gtkmm2ext/gtk_ui.cc +++ b/libs/gtkmm2ext/gtk_ui.cc @@ -73,12 +73,26 @@ BaseUI::RequestType Gtkmm2ext::AddTimeout = BaseUI::new_request_type(); template class AbstractUI; +#ifndef NDEBUG +static int debug_call_slot = -1; +#endif + UI::UI (string application_name, string thread_name, int *argc, char ***argv) : AbstractUI (thread_name) , _receiver (*this) , global_bindings (0) , errors (0) { +#ifndef NDEBUG + /* one time initialization of this to reduce run time cost in debug builds */ + if (debug_call_slot < 0) { + if (g_getenv ("DEBUG_THREADED_SIGNALS")) { + debug_call_slot = 1; + } else { + debug_call_slot = 0; + } + } +#endif theMain = new Main (argc, argv); char buf[18]; @@ -479,7 +493,7 @@ UI::do_request (UIRequest* req) } else if (req->type == CallSlot) { #ifndef NDEBUG - if (getenv ("DEBUG_THREADED_SIGNALS")) { + if (debug_call_slot) { cerr << "call slot for " << event_loop_name() << endl; } #endif