[calligra] krita: send signal to the node model before the image is deleted

Cyrille Berger Skott cberger at cberger.net
Sat Feb 26 18:51:15 CET 2011


Hi,

This breaks the following two unit tests:

http://my.cdash.org/viewUpdate.php?buildid=161746


On Saturday 26 February 2011, Sven Langkamp wrote:
> Git commit 4373a0517d8f3ead8b0b409b530747bd86c43ffb by Sven Langkamp.
> Committed on 26/02/2011 at 18:04.
> Pushed by langkamp into branch 'master'.
> 
> send signal to the node model before the image is deleted
> 
> M  +5    -0    krita/image/kis_image.cc
> M  +10   -0    krita/image/kis_image.h
> M  +1    -0    krita/ui/kis_doc2.cc
> M  +14   -2    krita/ui/kis_node_model.cpp
> M  +1    -0    krita/ui/kis_node_model.h
> 
> http://commits.kde.org/calligra/4373a0517d8f3ead8b0b409b530747bd86c43ffb
> 
> diff --git a/krita/image/kis_image.cc b/krita/image/kis_image.cc
> index 90461f9..44d979a 100644
> --- a/krita/image/kis_image.cc
> +++ b/krita/image/kis_image.cc
> @@ -1100,6 +1100,11 @@ vKisAnnotationSP_it KisImage::endAnnotations()
>      return m_d->annotations.end();
>  }
> 
> +void KisImage::notifyAboutToBeDeleted()
> +{
> +    emit sigAboutToBeDeleted();
> +}
> +
>  KisPerspectiveGrid* KisImage::perspectiveGrid()
>  {
>      if (m_d->perspectiveGrid == 0)
> diff --git a/krita/image/kis_image.h b/krita/image/kis_image.h
> index f4a25e4..9b081f8 100644
> --- a/krita/image/kis_image.h
> +++ b/krita/image/kis_image.h
> @@ -475,6 +475,11 @@ public:
>      /** end of an iteration over the annotations of this image */
>      vKisAnnotationSP_it endAnnotations();
> 
> +    /**
> +     * Called before the image is delted and sends the sigAboutToBeDeleted
> signal +     */
> +    void notifyAboutToBeDeleted();
> +
>  signals:
> 
>      /// Emitted after a layer's properties (visible, locked, opacity,
> composite op, name, ...) change @@ -546,6 +551,11 @@ signals:
>       */
>      void sigNodeChanged(KisNode * node);
> 
> +    /**
> +     * Inform that the image is going to be deleted
> +     */
> +    void sigAboutToBeDeleted();
> +
>  public slots:
> 
>      void slotProjectionUpdated(const QRect & rc);
> diff --git a/krita/ui/kis_doc2.cc b/krita/ui/kis_doc2.cc
> index 735e234..7033dc2 100644
> --- a/krita/ui/kis_doc2.cc
> +++ b/krita/ui/kis_doc2.cc
> @@ -166,6 +166,7 @@ KisDoc2::~KisDoc2()
>      delete m_d->shapeController;
>      delete m_d->nodeModel;
> 
> +    m_d->image->notifyAboutToBeDeleted();
>      // The following line trigger the deletion of the image
>      m_d->image.clear();
> 
> diff --git a/krita/ui/kis_node_model.cpp b/krita/ui/kis_node_model.cpp
> index 3d1614f..1dcb6d6 100644
> --- a/krita/ui/kis_node_model.cpp
> +++ b/krita/ui/kis_node_model.cpp
> @@ -82,6 +82,8 @@ void KisNodeModel::setImage(KisImageWSP image)
>              SLOT(endRemoveNodes(KisNode*, int)));
>      connect(m_d->image, SIGNAL(sigNodeChanged(KisNode*)),
>              SLOT(nodeChanged(KisNode*)));
> +    connect(m_d->image, SIGNAL(sigAboutToBeDeleted()),
> +            SLOT(imageDeleted()));
>  }
> 
>  KisNodeSP KisNodeModel::nodeFromIndex(const QModelIndex &index)
> @@ -131,6 +133,9 @@ QModelIndex KisNodeModel::indexFromNode(const KisNodeSP
> node) const int KisNodeModel::rowCount(const QModelIndex &parent) const
>  {
>      //dbgUI <<"KisNodeModel::rowCount" << parent;
> +    if (!m_d->image) {
> +        return 0;
> +    }
> 
>      if (!parent.isValid()) {
>          if (m_d->image) {
> @@ -159,7 +164,7 @@ QModelIndex KisNodeModel::index(int row, int column,
> const QModelIndex &parent) {
>      //dbgUI <<"KisNodeModel::index(row =" << row <<", column=" << column
> <<", parent=" << parent <<" parent is valid:" << parent.isValid();
> 
> -    if (!hasIndex(row, column, parent)) {
> +    if (!m_d->image || !hasIndex(row, column, parent)) {
>          //dbgUI << "Does not have index";
>          return QModelIndex();
>      }
> @@ -196,7 +201,8 @@ QModelIndex KisNodeModel::index(int row, int column,
> const QModelIndex &parent) QModelIndex KisNodeModel::parent(const
> QModelIndex &index) const
>  {
>      //dbgUI <<"KisNodeModel::parent " << index;
> -    if (!index.isValid())
> +    kDebug() << "image " << m_d->image;
> +    if (!m_d->image || !index.isValid())
>          return QModelIndex();
> 
>      Q_ASSERT(index.model() == this);
> @@ -508,4 +514,10 @@ void KisNodeModel::updateNodes()
>      m_d->updateQueue.clear();
>  }
> 
> +void KisNodeModel::imageDeleted()
> +{
> +    m_d->image = 0;
> +    reset();
> +}
> +
>  #include "kis_node_model.moc"
> diff --git a/krita/ui/kis_node_model.h b/krita/ui/kis_node_model.h
> index 08c9d5d..cb5085d 100644
> --- a/krita/ui/kis_node_model.h
> +++ b/krita/ui/kis_node_model.h
> @@ -81,6 +81,7 @@ private slots:
>      void nodeChanged(KisNode * node);
> 
>      void updateNodes();
> +    void imageDeleted();
> 
>  private:


-- 
Cyrille Berger Skott


More information about the kimageshop mailing list