[cairo] Fwd: [PATCH] Initialize mutexes for static builds for win32
Bryce Harrington
bryce at osg.samsung.com
Mon Aug 21 23:37:33 UTC 2017
On Mon, Jun 12, 2017 at 12:49:44PM +0200, Alexander Täschner wrote:
> Here is the revised patch.
This sounds safe enough to me, and presumably Uli is ok with the updated
version. I fixed the indentation error and landed it:
To ssh://git.freedesktop.org/git/cairo
339fe9a..5f90f0a master -> master
I'd encourage win32 users to test this usage case.
> Kind regards,
> Alexander Täschner
> ---
> src/win32/cairo-win32-device.c | 2 ++
> 1 file changed, 2 insertions(+)
> diff --git a/src/win32/cairo-win32-device.c b/src/win32/cairo-win32-device.c
> index 741e49e..3e959f6 100644
> --- a/src/win32/cairo-win32-device.c
> +++ b/src/win32/cairo-win32-device.c
> @@ -131,6 +131,8 @@ _cairo_win32_device_get (void)
> {
> cairo_win32_device_t *device;
>
> + CAIRO_MUTEX_INITIALIZE ();
> +
> if (__cairo_win32_device)
> return cairo_device_reference (__cairo_win32_device);
>
> --
> 2.10.2.windows.1
>
>
> 2017-06-10 14:38 GMT+02:00 Uli Schlachter <psychon at znc.in>:
>
> > On 07.06.2017 16:01, Alexander Täschner wrote:
> > > For static builds for win32 the mutexes are not initialized (for dynamic
> > > builds its done when the DLL is loaded). Therefore the patch add
> > > initialization to the create surface calls.
> > >
> > > ---
> > > src/win32/cairo-win32-display-surface.c | 8 ++++++--
> > > 1 file changed, 6 insertions(+), 2 deletions(-)
> > > diff --git a/src/win32/cairo-win32-display-surface.c
> > > b/src/win32/cairo-win32-display-surface.c
> > > index 025b2c9..56f0e65 100644
> > > --- a/src/win32/cairo-win32-display-surface.c
> > > +++ b/src/win32/cairo-win32-display-surface.c
> > > @@ -953,7 +953,9 @@ cairo_win32_surface_create_with_format (HDC hdc,
> > > cairo_format_t format)
> > > case CAIRO_FORMAT_RGB24:
> > > break;
> > > }
> > > -
> > > +#if CAIRO_WIN32_STATIC_BUILD
> > > + CAIRO_MUTEX_INITIALIZE ();
> > > +#endif
> > > surface = malloc (sizeof (*surface));
> > > if (surface == NULL)
> > > return _cairo_surface_create_in_error (_cairo_error
> > > (CAIRO_STATUS_NO_MEMORY));
> > > @@ -1031,7 +1033,9 @@ cairo_win32_surface_create_with_dib
> > (cairo_format_t
> > > format,
> > > {
> > > if (! CAIRO_FORMAT_VALID (format))
> > > return _cairo_surface_create_in_error (_cairo_error
> > > (CAIRO_STATUS_INVALID_FORMAT));
> > > -
> > > +#if CAIRO_WIN32_STATIC_BUILD
> > > + CAIRO_MUTEX_INITIALIZE ();
> > > +#endif
> > > return _cairo_win32_display_surface_create_for_dc (NULL, format,
> > > width, height);
> > > }
> >
> > I would suggest doing the above unconditionally (without the #if).
> >
> > Also, how about moving this to the beginning of
> > _cairo_win32_device_get()? That sounds central enough that every code
> > path in the win32 backend should go through it.
> >
> > Uli
> > --
> > 99 little bugs in the code
> > 99 little bugs in the code
> > Take one down, patch it around
> > 117 little bugs in the code
> > -- @irqed
> >
> --
> cairo mailing list
> cairo at cairographics.org
> https://lists.cairographics.org/mailman/listinfo/cairo
More information about the cairo
mailing list