From da58dd32b2ebad5cf02dd92273b8f14b4989a54c Mon Sep 17 00:00:00 2001 From: Lilith River <lilith@imazen.io> Date: Fri, 3 Jul 2020 13:49:10 -0600 Subject: [PATCH] Add ThreadContext::set_error_logging_function --- src/context.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/context.rs b/src/context.rs index 5fa797d..acb3d13 100644 --- a/src/context.rs +++ b/src/context.rs @@ -99,7 +99,7 @@ impl Context for ThreadContext { /// When you see an error "expected reference, found struct `lcms2::GlobalContext`", it means you've mixed global and thread-context objects. They don't work together. /// For example, if you create a `Transform` with a context (calling `new_*_context()`), then it will only support `Profile` with a context as well. pub struct ThreadContext { - handle: ffi::Context, + handle: ffi::Context } impl GlobalContext { @@ -187,8 +187,16 @@ impl ThreadContext { } tmp } + + /// Sets a function to be called if there is an error. + pub fn set_error_logging_function(&mut self, handler: ffi::LogErrorHandlerFunction) { + unsafe { + ffi::cmsSetLogErrorHandlerTHR(self.handle, handler) + } + } } + impl Clone for ThreadContext { fn clone(&self) -> Self { unsafe { Self::new_handle(ffi::cmsDupContext(self.handle, ptr::null_mut())) } -- GitLab