[Calligra] eb493aa check whether the image wsp is valid

Boudewijn Rempt boud at valdyas.org
Wed Jan 5 10:41:39 CET 2011


commit eb493aa2b562b0a384899b2327501ac058171aaf
branch master
Author: Boudewijn Rempt <boud at valdyas.org>
Date:   Wed Jan 5 10:36:19 2011 +0100

    check whether the image wsp is valid
    
    We should check whether a weak shared pointer is valid, instead
    of checking the pointer -- which isn't set to 0 after the corresponding
    shared pointer is deleted.
    
    Should be backported to 2.3.
    
    CCMAIL:kimageshop at kde.org
    
    BUG:261940

diff --git a/krita/image/kis_layer.cc b/krita/image/kis_layer.cc
index c28983c..f661142 100644
--- a/krita/image/kis_layer.cc
+++ b/krita/image/kis_layer.cc
@@ -140,7 +140,7 @@ KisLayer::~KisLayer()
 
 const KoColorSpace * KisLayer::colorSpace() const
 {
-    if (m_d->image)
+    if (m_d->image.isValid())
         return m_d->image->colorSpace();
     return 0;
 }
@@ -252,7 +252,7 @@ KisSelectionSP KisLayer::selection() const
 
     if (layer->selectionMask())
         return layer->selectionMask()->selection();
-    else if (m_d->image)
+    else if (m_d->image.isValid())
         return m_d->image->globalSelection();
     else
         return KisSelectionSP(new KisSelection());
diff --git a/krita/ui/canvas/kis_coordinates_converter.cpp b/krita/ui/canvas/kis_coordinates_converter.cpp
index c922b24..e7158f9 100644
--- a/krita/ui/canvas/kis_coordinates_converter.cpp
+++ b/krita/ui/canvas/kis_coordinates_converter.cpp
@@ -45,7 +45,7 @@ struct KisCoordinatesConverter::Private {
 
 void KisCoordinatesConverter::recalculateTransformations() const
 {
-    if(!m_d->image) return;
+    if(!m_d->image.isValid()) return;
 
     m_d->imageToDocument = QTransform::fromScale(1 / m_d->image->xRes(),
                                                  1 / m_d->image->yRes());
@@ -238,19 +238,19 @@ void KisCoordinatesConverter::getOpenGLCheckersInfo(QTransform *textureTransform
 
 QRectF KisCoordinatesConverter::imageRectInWidgetPixels() const
 {
-    if(!m_d->image) return QRectF();
+    if(!m_d->image.isValid()) return QRectF();
     return viewportToWidget(imageToViewport(m_d->image->bounds()));
 }
 
 QRectF KisCoordinatesConverter::imageRectInViewportPixels() const
 {
-    if(!m_d->image) return QRectF();
+    if(!m_d->image.isValid()) return QRectF();
     return imageToViewport(m_d->image->bounds());
 }
 
 QSizeF KisCoordinatesConverter::imageSizeInFlakePixels() const
 {
-    if(!m_d->image) return QSizeF();
+    if(!m_d->image.isValid()) return QSizeF();
 
     qreal scaleX, scaleY;
     imageScale(&scaleX, &scaleY);
diff --git a/krita/ui/flake/kis_shape_controller.cpp b/krita/ui/flake/kis_shape_controller.cpp
index 1ee800f..25f87f6 100644
--- a/krita/ui/flake/kis_shape_controller.cpp
+++ b/krita/ui/flake/kis_shape_controller.cpp
@@ -162,7 +162,7 @@ KisShapeController::~KisShapeController()
 
 void KisShapeController::setImage(KisImageWSP image)
 {
-    if (m_d->image) {
+    if (m_d->image.isValid()) {
         m_d->image->disconnect(this);
         m_d->removeNodeShape(m_d->rootNode);
 


More information about the kimageshop mailing list