DVCPRO fix
[melted] / src / modules / gtk2 / producer_pango.c
index b868063..37b1abb 100644 (file)
@@ -88,6 +88,8 @@ static int alignment_parse( char* align )
        return ret;
 }
 
+static PangoFT2FontMap *fontmap = NULL;
+
 mlt_producer producer_pango_init( const char *filename )
 {
        producer_pango this = calloc( sizeof( struct producer_pango_s ), 1 );
@@ -95,6 +97,10 @@ mlt_producer producer_pango_init( const char *filename )
        {
                mlt_producer producer = &this->parent;
 
+               // THIS SHOULD BE MUTEXED...
+               if ( fontmap == NULL )
+                       fontmap = (PangoFT2FontMap*) pango_ft2_font_map_new();
+
                producer->get_frame = producer_get_frame;
                producer->close = ( mlt_destructor )producer_close;
 
@@ -444,7 +450,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        {
                // Clone our image
                uint8_t *copy = mlt_pool_alloc( size );
-               if ( copy != NULL )
+               if ( copy != NULL && image != NULL )
                        memcpy( copy, image, size );
 
                // We're going to pass the copy on
@@ -540,7 +546,6 @@ static void pango_draw_background( GdkPixbuf *pixbuf, rgba_color bg )
 
 static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, const char *font, rgba_color fg, rgba_color bg, int pad, int align, int weight, int size )
 {
-       PangoFT2FontMap *fontmap = (PangoFT2FontMap*) pango_ft2_font_map_new();
        PangoContext *context = pango_ft2_font_map_create_context( fontmap );
        PangoLayout *layout = pango_layout_new( context );
        int w, h, x;
@@ -607,9 +612,9 @@ static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, const
                src += bitmap.pitch;
        }
        mlt_pool_release( bitmap.buffer );
+       pango_font_description_free( desc );
        g_object_unref( layout );
        g_object_unref( context );
-       g_object_unref( fontmap );
 
        return pixbuf;
 }