[AD] [patch] register_trace_handler() MacOS/DirectX issue

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


The DirectX and MacOS drivers call register_trace_handler() when the user calls install_allegro(). This means it's not possible to register a handler for all messages. If you register one after installing Allegro, you will at least get the "Allegro initialised" message, and the allegro.log file will be created in the CWD.

--
Daniel Schlyder
Index: include/allegro/internal/aintern.h
===================================================================
--- include/allegro/internal/aintern.h	(revision 7546)
+++ include/allegro/internal/aintern.h	(working copy)
@@ -59,6 +59,9 @@
 AL_VAR(int, _screensaver_policy);
 
 
+AL_FUNCPTR(int, _al_trace_handler, (AL_CONST char *msg));
+
+
 /* malloc wrappers */
 /* The 4.3 branch uses the following macro names to allow the user to customise
  * the memory management routines.  We don't have that feature in 4.2, but we
Index: src/allegro.c
===================================================================
--- src/allegro.c	(revision 7546)
+++ src/allegro.c	(working copy)
@@ -207,7 +207,7 @@
 static FILE *trace_file = NULL;
 
 static int (*assert_handler)(AL_CONST char *msg) = NULL;
-static int (*trace_handler)(AL_CONST char *msg) = NULL;
+int (*_al_trace_handler)(AL_CONST char *msg) = NULL;
 
 
 /* Module linking system stuff: if an object file is linked in, then its
@@ -645,8 +645,8 @@
    vsprintf(buf, msg, ap);
    va_end(ap);
 
-   if (trace_handler) {
-      if (trace_handler(buf))
+   if (_al_trace_handler) {
+      if (_al_trace_handler(buf))
 	 return;
    }
 
@@ -689,7 +689,7 @@
  */
 void register_trace_handler(int (*handler)(AL_CONST char *msg))
 {
-   trace_handler = handler;
+   _al_trace_handler = handler;
 }
 
 
Index: src/mac/msys.c
===================================================================
--- src/mac/msys.c	(revision 7546)
+++ src/mac/msys.c	(working copy)
@@ -153,7 +153,8 @@
 {
    os_type = OSTYPE_MACOS;
    os_multitasking = TRUE;
-   register_trace_handler(mac_trace_handler);
+   if (!_al_trace_handler)
+      register_trace_handler(mac_trace_handler);
 #if (TRACE_MAC_SYSTEM)
    fprintf(stdout, "mac_init()::OK\n");
    fflush(stdout);
Index: src/win/wsystem.c
===================================================================
--- src/win/wsystem.c	(revision 7546)
+++ src/win/wsystem.c	(working copy)
@@ -182,7 +182,8 @@
    InitializeCriticalSection(&allegro_critical_section);
 
    /* install a Windows specific trace handler */
-   register_trace_handler(sys_directx_trace_handler);
+   if (!_al_trace_handler)
+      register_trace_handler(sys_directx_trace_handler);
 
    /* setup the display switch system */
    sys_directx_display_switch_init();


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/