Changeset 183

Show
Ignore:
Timestamp:
05/13/06 09:52:37 (2 years ago)
Author:
jordi
Message:

I forget to check if the poppler page could be retrieved in some functions, causing a segmentation fault in some cases. See #22.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/PDFDocument.cxx

    r163 r183  
    367367 
    368368    PopplerPage *page = poppler_document_get_page (m_Document, pageNum - 1); 
    369  
    370     gdouble pageWidth; 
    371     gdouble pageHeight; 
    372     // Check which rotation has the document's page to know what is width 
    373     // and what is height. 
    374     gint rotate = getRotation (); 
    375     if ( 90 == rotate || 270 == rotate ) 
    376     { 
    377         poppler_page_get_size (page, &pageHeight, &pageWidth); 
    378     } 
    379     else  
    380     { 
    381         poppler_page_get_size (page, &pageWidth, &pageHeight); 
    382     } 
    383  
    384     *width = pageWidth; 
    385     *height = pageHeight; 
    386  
    387     g_object_unref (G_OBJECT (page)); 
     369    if ( NULL != page ) 
     370    { 
     371        gdouble pageWidth; 
     372        gdouble pageHeight; 
     373        // Check which rotation has the document's page to know what is width 
     374        // and what is height. 
     375        gint rotate = getRotation (); 
     376        if ( 90 == rotate || 270 == rotate ) 
     377        { 
     378            poppler_page_get_size (page, &pageHeight, &pageWidth); 
     379        } 
     380        else  
     381        { 
     382            poppler_page_get_size (page, &pageWidth, &pageHeight); 
     383        } 
     384 
     385        *width = pageWidth; 
     386        *height = pageHeight; 
     387 
     388        g_object_unref (G_OBJECT (page)); 
     389    } 
     390    else 
     391    { 
     392        // Just give any valor, except 0. 
     393        *width = 1.0; 
     394        *height = 1.0; 
     395    } 
    388396} 
    389397 
     
    425433                                                  NULL, NULL); 
    426434    PopplerPage *page = poppler_document_get_page (m_Document, pageNum - 1); 
    427     poppler_page_render_to_pixbuf (page, 0, 0, width, height, getZoom (), 
    428                                    getRotation (), pixbuf); 
     435    if ( NULL != page ) 
     436    { 
     437        poppler_page_render_to_pixbuf (page, 0, 0, width, height, getZoom (), 
     438                                       getRotation (), pixbuf); 
     439        setLinks (renderedPage, page); 
     440        g_object_unref (G_OBJECT (page)); 
     441    } 
    429442    g_object_unref (pixbuf); 
    430     setLinks (renderedPage, page); 
    431     g_object_unref (G_OBJECT (page)); 
    432443     
    433444    return (renderedPage);