Code

Avoid crashing when profile is missing. Addresses main symptom of bug #437927.
authorjoncruz <joncruz@users.sourceforge.net>
Tue, 29 Sep 2009 05:31:51 +0000 (05:31 +0000)
committerjoncruz <joncruz@users.sourceforge.net>
Tue, 29 Sep 2009 05:31:51 +0000 (05:31 +0000)
src/color-profile.cpp
src/widgets/sp-color-icc-selector.cpp

index 37ebc4f30fe312da483855a8f6cc09440785053c..9b05aaa7efdd3f8d52c39445e5e59be89ebc57ef 100644 (file)
@@ -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 );
     }
index 916e4363c9dbf5c0511cb7a4a746cd0ea934a67e..a10d2380ca192cc418f8ef2b3603b816173432e3 100644 (file)
@@ -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();