[Libreoffice] Reporting an error when loading of a component fails

Lubos Lunak l.lunak at suse.cz
Thu Aug 4 04:04:39 PDT 2011


On Wednesday 03 of August 2011, Caolán McNamara wrote:
> On Tue, 2011-08-02 at 14:58 +0200, Lubos Lunak wrote:
> > - osl_loadModule*() functions are plain C functions from stable API, so
> > no overloading to add the extra argument for the error message, the best
> > I've come up with was simply a wrapper around dlerror(), which I admit is
> > not very nice API either, would there be any better approach?
>
> Has the obvious issue of an gap between error and retrieving the error
> and some other thread churning away in between, how about...

 That's already inherent in dlerror() itself, I have no idea how this is 
handled on Windows.

> A oslModule is a void* and we're currently just directly casting the
> return from dlopen (and the windows equivalent) to a oslModule
>
> Maybe one possibility is instead a private struct like
>
> struct unx_impl_Module
> {
> 	void *m_pRealHandle;
> 	const char *m_pLastError;
> };
>
> in osl/unx/module.c, malloc one of those and return *that* as the
> oslModule from the osl_loadModule* family. Free it in osl_unloadModule.
> Do the fixup in the various methods to cast oslModule to unx_impl_Module
> and get the realhandle out of it for the dl* family. Now can add a new
> toplevel osl c-function to check for error.
>
> oslModule stays a void* and all should remain abi-groovy methinks ?

 That is a clever hack, but API-wise I consider it so ugly that I'd rather 
prefer the extra osl_loadModuleWithError() variants than this.

-- 
 Lubos Lunak
 l.lunak at suse.cz


More information about the LibreOffice mailing list