From 17265630bbc582eda06b0dfc0ebdb8febc4362c5 Mon Sep 17 00:00:00 2001 From: joncruz Date: Tue, 29 Sep 2009 05:31:51 +0000 Subject: [PATCH] Avoid crashing when profile is missing. Addresses main symptom of bug #437927. --- src/color-profile.cpp | 4 ++-- src/widgets/sp-color-icc-selector.cpp | 27 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 37ebc4f30..9b05aaa7e 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -487,7 +487,7 @@ cmsHPROFILE Inkscape::colorprofile_get_handle( SPDocument* document, guint* inte cmsHTRANSFORM ColorProfile::getTransfToSRGB8() { - if ( !_transf ) { + if ( !_transf && profHandle ) { int intent = getLcmsIntent(rendering_intent); _transf = cmsCreateTransform( profHandle, _getInputFormat(_profileSpace), getSRGBProfile(), TYPE_RGBA_8, intent, 0 ); } @@ -496,7 +496,7 @@ cmsHTRANSFORM ColorProfile::getTransfToSRGB8() cmsHTRANSFORM ColorProfile::getTransfFromSRGB8() { - if ( !_revTransf ) { + if ( !_revTransf && profHandle ) { int intent = getLcmsIntent(rendering_intent); _revTransf = cmsCreateTransform( getSRGBProfile(), TYPE_RGBA_8, profHandle, _getInputFormat(_profileSpace), intent, 0 ); } diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 916e4363c..a10d2380c 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -637,14 +637,17 @@ void ColorICCSelector::_colorChanged() tmp[i] = val * 0x0ffff; } guchar post[4] = {0,0,0,0}; - cmsDoTransform( _prof->getTransfToSRGB8(), tmp, post, 1 ); - guint32 other = SP_RGBA32_U_COMPOSE(post[0], post[1], post[2], 255 ); - if ( other != _color.toRGBA32(255) ) { - _fixupNeeded = other; - gtk_widget_set_sensitive( _fixupBtn, TRUE ); + cmsHTRANSFORM trans = _prof->getTransfToSRGB8(); + if ( trans ) { + cmsDoTransform( trans, tmp, post, 1 ); + guint32 other = SP_RGBA32_U_COMPOSE(post[0], post[1], post[2], 255 ); + if ( other != _color.toRGBA32(255) ) { + _fixupNeeded = other; + gtk_widget_set_sensitive( _fixupBtn, TRUE ); #ifdef DEBUG_LCMS - g_message("Color needs to change 0x%06x to 0x%06x", _color.toRGBA32(255) >> 8, other >> 8 ); + g_message("Color needs to change 0x%06x to 0x%06x", _color.toRGBA32(255) >> 8, other >> 8 ); #endif // DEBUG_LCMS + } } } #else @@ -773,8 +776,11 @@ void ColorICCSelector::_updateSliders( gint ignore ) } } - cmsDoTransform( _prof->getTransfToSRGB8(), scratch, _fooMap[i], 1024 ); - sp_color_slider_set_map( SP_COLOR_SLIDER(_fooSlider[i]), _fooMap[i] ); + cmsHTRANSFORM trans = _prof->getTransfToSRGB8(); + if ( trans ) { + cmsDoTransform( trans, scratch, _fooMap[i], 1024 ); + sp_color_slider_set_map( SP_COLOR_SLIDER(_fooSlider[i]), _fooMap[i] ); + } } } } @@ -840,7 +846,10 @@ void ColorICCSelector::_adjustmentChanged( GtkAdjustment *adjustment, SPColorICC } guchar post[4] = {0,0,0,0}; - cmsDoTransform( iccSelector->_prof->getTransfToSRGB8(), tmp, post, 1 ); + cmsHTRANSFORM trans = iccSelector->_prof->getTransfToSRGB8(); + if ( trans ) { + cmsDoTransform( trans, tmp, post, 1 ); + } SPColor other( SP_RGBA32_U_COMPOSE(post[0], post[1], post[2], 255) ); other.icc = new SVGICCColor(); -- 2.30.2