Changeset 281

Show
Ignore:
Timestamp:
08/24/07 10:51:34 (16 months ago)
Author:
jordi
Message:

Added check to prevent segfaults while opening the print dialog if the PPD file doesn't have the option that was requrested.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/PrintPter.cxx

    r262 r281  
    231231                view.clearPageSizeList (); 
    232232                int pageSizeToSelect = 0; 
    233                 ppd_choice_t *pageSizeChoice = pageSizeOption->choices; 
    234                 for ( int currentSize = 0 ; 
    235                       currentSize < pageSizeOption->num_choices ; 
    236                       ++currentSize, ++pageSizeChoice ) 
    237                 { 
    238                     const gchar *sizeName = pageSizeChoice->text; 
    239                     const gchar *sizeValue = pageSizeChoice->choice; 
    240  
    241                     view.addPageSize (_(sizeName), sizeValue); 
    242                     if ( pageSizeChoice->marked ) 
     233                if ( 0 != pageSizeOption ) 
     234                { 
     235                    ppd_choice_t *pageSizeChoice = pageSizeOption->choices; 
     236                    for ( int currentSize = 0 ; 
     237                         currentSize < pageSizeOption->num_choices ; 
     238                         ++currentSize, ++pageSizeChoice ) 
    243239                    { 
    244                         pageSizeToSelect = currentSize; 
     240                        const gchar *sizeName = pageSizeChoice->text; 
     241                        const gchar *sizeValue = pageSizeChoice->choice; 
     242 
     243                        view.addPageSize (_(sizeName), sizeValue); 
     244                        if ( pageSizeChoice->marked ) 
     245                        { 
     246                            pageSizeToSelect = currentSize; 
     247                        } 
    245248                    } 
     249                } 
     250                else 
     251                { 
     252                    view.addPageSize (_("A4"), "A4"); 
    246253                } 
    247254                view.selectPageSize (pageSizeToSelect); 
     
    252259                view.clearResolutionList (); 
    253260                int resolutionToSelect = 0; 
    254                 ppd_choice_t *resolutionChoice = resolutionOption->choices; 
    255                 for ( int currentRes = 0 ; 
    256                       currentRes < resolutionOption->num_choices ; 
    257                       ++currentRes, ++resolutionChoice ) 
    258                 { 
    259                     const gchar *resName = resolutionChoice->text; 
    260                     const gchar *resValue = resolutionChoice->choice; 
    261  
    262                     view.addResolution (_(resName), resValue); 
    263                     if ( resolutionChoice->marked ) 
     261                if ( 0 != resolutionOption ) 
     262                { 
     263                    ppd_choice_t *resolutionChoice = resolutionOption->choices; 
     264                    for ( int currentRes = 0 ; 
     265                            currentRes < resolutionOption->num_choices ; 
     266                            ++currentRes, ++resolutionChoice ) 
    264267                    { 
    265                         resolutionToSelect = currentRes; 
     268                        const gchar *resName = resolutionChoice->text; 
     269                        const gchar *resValue = resolutionChoice->choice; 
     270 
     271                        view.addResolution (_(resName), resValue); 
     272                        if ( resolutionChoice->marked ) 
     273                        { 
     274                            resolutionToSelect = currentRes; 
     275                        } 
    266276                    } 
     277                } 
     278                else 
     279                { 
     280                    view.addResolution (_("300 DPI"), "300x300dpi"); 
    267281                } 
    268282                view.selectResolution (resolutionToSelect); 
     
    272286                    ppdFindOption (printerPPD, "ColorModel"); 
    273287                view.clearColorModelList (); 
     288                int colorModelToSelect = 0; 
    274289                if ( NULL != colorModelOption ) 
    275290                { 
    276                     int colorModelToSelect = 0; 
    277291                    ppd_choice_t *colorModelChoice = colorModelOption->choices; 
    278292                    for ( int currentColor = 0 ; 
     
    289303                        } 
    290304                    } 
    291                     view.selectColorModel (colorModelToSelect); 
    292305                } 
    293306                else 
     
    295308                    view.addColorModel (_("Grayscale"), "Gray"); 
    296309                } 
     310                view.selectColorModel (colorModelToSelect); 
    297311                ppdClose (printerPPD); 
    298312            }