mscms: Handle errors from lcms more gracefully.

Hans Leidekker hans at codeweavers.com
Thu Mar 5 05:11:30 CST 2009


Default behavior of lcms is to abort the process when it encounters
an error it considers fatal, such as a corrupt color profile.

Fixes http://bugs.winehq.org/show_bug.cgi?id=17452

 -Hans

diff --git a/dlls/mscms/mscms_main.c b/dlls/mscms/mscms_main.c
index 00e2a75..3199c0b 100644
--- a/dlls/mscms/mscms_main.c
+++ b/dlls/mscms/mscms_main.c
@@ -36,6 +36,23 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(mscms);
 
+#ifdef HAVE_LCMS
+static int lcms_error_handler( int error, const char *text )
+{
+    switch (error)
+    {
+    case LCMS_ERRC_WARNING:
+    case LCMS_ERRC_RECOVERABLE:
+    case LCMS_ERRC_ABORTED:
+        WARN("%d %s\n", error, debugstr_a(text));
+        return 1;
+    default:
+        ERR("unknown error %d %s\n", error, debugstr_a(text));
+        return 0;
+    }
+}
+#endif
+
 BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
 {
     TRACE( "(%p, %d, %p)\n", hinst, reason, reserved );
@@ -44,6 +61,9 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
     {
     case DLL_PROCESS_ATTACH:
         DisableThreadLibraryCalls( hinst );
+#ifdef HAVE_LCMS
+        cmsSetErrorHandler( lcms_error_handler );
+#endif
         break;
     case DLL_PROCESS_DETACH:
 #ifdef HAVE_LCMS



More information about the wine-patches mailing list