Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 28c2ff72 authored by Cyrille Berger's avatar Cyrille Berger

fix the weak pointer and memory leak

rename parent to parentLayer to avoid badly overriding QObject's function
and also commit what's needed for the drag and drop to nearly work in the model (as a side effects of above changed)

svn path=/trunk/koffice/; revision=663650
parent 6127f6e2
......@@ -33,7 +33,7 @@
#include "kis_merge_visitor.h"
#include "kis_fill_painter.h"
KisGroupLayer::KisGroupLayer(KisImageSP img, const QString &name, quint8 opacity) :
KisGroupLayer::KisGroupLayer(KisImageWSP img, const QString &name, quint8 opacity) :
KisLayer(img, name, opacity),
m_x(0),
m_y(0)
......@@ -114,7 +114,7 @@ KisPaintDeviceSP KisGroupLayer::projection()
{
// We don't have a parent, and we've got only one child: abuse the child's
// paint device as the projection if the child is visible
if (parent().isNull() && childCount() == 1) {
if (parentLayer().isNull() && childCount() == 1) {
KisPaintLayerSP l = KisPaintLayerSP(dynamic_cast<KisPaintLayer*>(firstChild().data()));
if (paintLayerInducesProjectionOptimization(l)) {
return l->paintDevice();
......@@ -147,7 +147,7 @@ KisLayerSP KisGroupLayer::at(int index) const
int KisGroupLayer::index(KisLayerSP layer) const
{
if (layer->parent().data() == this)
if (layer->parentLayer().data() == this)
return layer->index();
return -1;
}
......@@ -185,7 +185,7 @@ bool KisGroupLayer::addLayer(KisLayerSP newLayer, int x)
bool KisGroupLayer::addLayer(KisLayerSP newLayer, KisLayerSP aboveThis)
{
kDebug() << "KisGroupLayer::addLayer new layer: " << newLayer.data() << ", aboveThis " << aboveThis << endl;
if (aboveThis && aboveThis->parent().data() != this)
if (aboveThis && aboveThis->parentLayer().data() != this)
{
kWarning() << "invalid input to KisGroupLayer::addLayer(KisLayerSP newLayer, KisLayerSP aboveThis)!" << endl;
return false;
......@@ -223,7 +223,7 @@ bool KisGroupLayer::removeLayer(int x)
bool KisGroupLayer::removeLayer(KisLayerSP layer)
{
if (layer->parent().data() != this)
if (layer->parentLayer().data() != this)
{
kWarning() << "invalid input to KisGroupLayer::removeLayer()!" << endl;
return false;
......
......@@ -40,7 +40,7 @@ class KRITAIMAGE_EXPORT KisGroupLayer : public KisLayer {
Q_OBJECT
public:
KisGroupLayer(KisImageSP img, const QString &name, quint8 opacity);
KisGroupLayer(KisImageWSP img, const QString &name, quint8 opacity);
KisGroupLayer(const KisGroupLayer& rhs);
virtual ~KisGroupLayer();
......
......@@ -291,7 +291,7 @@ void KisImage::notifyLayerUpdated(KisLayerSP layer)
{
if( !m_d->dirtyLayers.contains( l ) )
m_d->dirtyLayers.append( l );
l = l->parent().data();
l = l->parentLayer().data();
}
}
......@@ -642,7 +642,7 @@ KisLayerSP KisImage::newLayer(const QString& name, quint8 opacity, const QString
KisLayerSP layerSP(layer);
if (!m_d->activeLayer.isNull()) {
addLayer(layerSP, m_d->activeLayer->parent(), m_d->activeLayer->nextSibling());
addLayer(layerSP, m_d->activeLayer->parentLayer(), m_d->activeLayer->nextSibling());
}
else {
addLayer(layerSP, m_d->rootLayer, KisLayerSP(0));
......@@ -774,7 +774,7 @@ bool KisImage::removeLayer(KisLayerSP layer)
if (!layer || layer->image() != this)
return false;
if (KisGroupLayerSP parent = layer->parent()) {
if (KisGroupLayerSP parent = layer->parentLayer()) {
// Adjustment layers should mark the layers underneath them, whose rendering
// they have cached, dirty on removal. Otherwise, the group won't be re-rendered.
KisAdjustmentLayer * al = dynamic_cast<KisAdjustmentLayer*>(layer.data());
......@@ -840,7 +840,7 @@ bool KisImage::raiseLayer(KisLayerSP layer)
{
if (!layer)
return false;
return moveLayer(layer, layer->parent(), layer->prevSibling());
return moveLayer(layer, layer->parentLayer(), layer->prevSibling());
}
bool KisImage::lowerLayer(KisLayerSP layer)
......@@ -848,7 +848,7 @@ bool KisImage::lowerLayer(KisLayerSP layer)
if (!layer)
return false;
if (KisLayerSP next = layer->nextSibling())
return moveLayer(layer, layer->parent(), next->nextSibling());
return moveLayer(layer, layer->parentLayer(), next->nextSibling());
return false;
}
......@@ -871,7 +871,7 @@ bool KisImage::moveLayer(KisLayerSP layer, KisGroupLayerSP parent, KisLayerSP ab
if (!parent)
return false;
KisGroupLayerSP wasParent = layer->parent();
KisGroupLayerSP wasParent = layer->parentLayer();
KisLayerSP wasAbove = layer->nextSibling();
if (wasParent.data() == parent.data() && wasAbove.data() == aboveThis.data())
......@@ -968,7 +968,7 @@ void KisImage::mergeLayer(KisLayerSP layer)
layer->accept(visitor);
removeLayer(layer->nextSibling());
addLayer(KisLayerSP(player), layer->parent(), layer);
addLayer(KisLayerSP(player), layer->parentLayer(), layer);
removeLayer(layer);
undoAdapter()->endMacro();
......
......@@ -191,7 +191,7 @@ KisImageLayerAddCommand::KisImageLayerAddCommand(KisImageSP image, KisLayerSP la
: super(i18n("Add Layer"), image)
{
m_layer = layer;
m_parent = layer->parent();
m_parent = layer->parentLayer();
m_aboveThis = layer->nextSibling();
}
......@@ -234,7 +234,7 @@ KisImageLayerMoveCommand::KisImageLayerMoveCommand(KisImageSP image, KisLayerSP
m_layer = layer;
m_prevParent = wasParent;
m_prevAbove = wasAbove;
m_newParent = layer->parent();
m_newParent = layer->parentLayer();
m_newAbove = layer->nextSibling();
}
......
......@@ -48,8 +48,8 @@ public:
bool temporary;
QString name;
KisGroupLayerSP parent;
KisImageSP image;
KisGroupLayerWSP parent;
KisImageWSP image;
QBitArray channelFlags;
// Operation used to composite this layer with the projection of
......@@ -61,7 +61,7 @@ public:
};
KisLayer::KisLayer(KisImageSP img, const QString &name, quint8 opacity)
KisLayer::KisLayer(KisImageWSP img, const QString &name, quint8 opacity)
: QObject(0)
, m_d( new Private )
{
......@@ -99,6 +99,7 @@ KisLayer::KisLayer(const KisLayer& rhs)
KisLayer::~KisLayer()
{
kDebug() << "~~~~~~~~~~ delete " << this << endl;
}
KoColorSpace * KisLayer::colorSpace()
......@@ -201,23 +202,28 @@ void KisLayer::setClean( QRect rc )
int KisLayer::id() const { return m_d->id; }
KisGroupLayerSP KisLayer::parent() const
KisGroupLayerSP KisLayer::parentLayer()
{
return m_d->parent;
}
const KisGroupLayerSP KisLayer::parentLayer() const
{
return m_d->parent;
}
KisLayerSP KisLayer::prevSibling() const
{
if (!parent())
if (!parentLayer())
return KisLayerSP(0);
return parent()->at(index() - 1);
return parentLayer()->at(index() - 1);
}
KisLayerSP KisLayer::nextSibling() const
{
if (!parent())
if (!parentLayer())
return KisLayerSP(0);
return parent()->at(index() + 1);
return parentLayer()->at(index() + 1);
}
int KisLayer::index() const
......@@ -407,7 +413,9 @@ void KisLayer::setCompositeOpPrivate( const KoCompositeOp * op )
void KisLayer::setParentPrivate( KisGroupLayerSP parent )
{
kDebug() << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " << this << " " << parent.data() << endl;
m_d->parent = parent;
kDebug() << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " << this << " " << m_d->parent.data() << endl;
}
void KisIndirectPaintingSupport::setTemporaryTarget(KisPaintDeviceSP t) {
......
......@@ -57,7 +57,7 @@ class KRITAIMAGE_EXPORT KisLayer: public QObject, public KisShared
Q_OBJECT
public:
KisLayer(KisImageSP img, const QString &name, quint8 opacity);
KisLayer(KisImageWSP img, const QString &name, quint8 opacity);
KisLayer(const KisLayer& rhs);
virtual ~KisLayer();
......@@ -122,7 +122,9 @@ public:
/**
* Returns the parent layer of a layer. This is 0 only for a root layer; otherwise
* this will be an actual GroupLayer */
virtual KisGroupLayerSP parent() const;
virtual KisGroupLayerSP parentLayer();
virtual const KisGroupLayerSP parentLayer() const;
/**
* Returns the previous sibling of this layer in the parent's list. This is the layer
......
......@@ -24,6 +24,7 @@
#include "kis_types.h"
#include "kis_paint_device.h"
#include "kis_layer.h"
class KisMask::KisMaskPrivate
{
......
......@@ -58,7 +58,7 @@ class KisPaintDevice::Private {
public:
KisLayer * parentLayer;
KisLayerWSP parentLayer;
quint8* defaultPixel;
bool extentIsValid;
qint32 x;
......@@ -189,7 +189,7 @@ KisPaintDevice::KisPaintDevice(KoColorSpace * colorSpace, const QString& name)
}
KisPaintDevice::KisPaintDevice(KisLayer *parent, KoColorSpace * colorSpace, const QString& name)
KisPaintDevice::KisPaintDevice(KisLayerWSP parent, KoColorSpace * colorSpace, const QString& name)
: QObject(0)
, m_d( new Private() )
{
......@@ -350,7 +350,7 @@ void KisPaintDevice::startBackgroundFilters()
}
}
KisLayer *KisPaintDevice::parentLayer() const
KisLayerSP KisPaintDevice::parentLayer() const
{
return m_d->parentLayer;
}
......
......@@ -92,7 +92,7 @@ public:
* @param colorSpace the colorspace of this paint device
* @param name for debugging purposes
*/
KisPaintDevice(KisLayer *parentLayer, KoColorSpace * colorSpace, const QString& name = QString());
KisPaintDevice(KisLayerWSP parentLayer, KoColorSpace * colorSpace, const QString& name = QString());
KisPaintDevice(const KisPaintDevice& rhs);
virtual ~KisPaintDevice();
......@@ -405,7 +405,7 @@ public:
* Returns the KisLayer that contains this paint device, or 0 if this is not
* part of a layer.
*/
KisLayer *parentLayer() const;
KisLayerSP parentLayer() const;
/**
* Set the KisLayer that contains this paint device, or 0 if this is not
......
......@@ -56,8 +56,8 @@ private:
class KisProjection::Private {
public:
KisImageSP image;
KisGroupLayerSP rootLayer;
KisImageWSP image;
KisGroupLayerWSP rootLayer;
QRegion dirtyRegion; // The Qt manual assures me that QRegion is
// threadsafe... Let's hope that's really
......@@ -68,7 +68,7 @@ public:
};
KisProjection::KisProjection( KisImageSP image, KisGroupLayerSP rootLayer )
KisProjection::KisProjection( KisImageWSP image, KisGroupLayerWSP rootLayer )
{
m_d = new Private();
m_d->image = image;
......
......@@ -57,7 +57,7 @@ class KisProjection : public QObject {
public:
KisProjection( KisImageSP image, KisGroupLayerSP rootLayer );
KisProjection( KisImageWSP image, KisGroupLayerWSP rootLayer );
virtual ~KisProjection();
/**
......
......@@ -60,7 +60,7 @@ class KisSharedPtr {
* Unreferences the object that this pointer points to. If it was
* the last reference, the object will be deleted.
*/
inline ~KisSharedPtr() { if (d && !d->ref.deref()) delete d; }
inline ~KisSharedPtr() { if (d && !d->ref.deref()) { delete d; } }
inline KisSharedPtr<T>& operator= ( const KisSharedPtr& o ) { attach(o.d); return *this; }
inline const KisSharedPtr<T>& operator= ( const KisSharedPtr& o ) const {
......@@ -117,8 +117,6 @@ class KisSharedPtr {
mutable T* d;
};
/**
* XXX!
*/
......@@ -143,7 +141,9 @@ class KisWeakSharedPtr {
}
inline KisWeakSharedPtr<T>( const KisSharedPtr<T>& o )
: d(o.d) { if(d) dataPtr = d->dataPtr; }
: d(o.d) {
if(d) dataPtr = d->dataPtr;
}
/**
* Copies a pointer.
* @param o the pointer to copy
......@@ -151,7 +151,10 @@ class KisWeakSharedPtr {
inline KisWeakSharedPtr<T>( const KisWeakSharedPtr<T>& o )
: d(o.d) { if(d) dataPtr = d->dataPtr; }
inline KisWeakSharedPtr<T>& operator= ( const KisWeakSharedPtr& o ) { attach(o.d); return *this; }
inline KisWeakSharedPtr<T>& operator= ( const KisWeakSharedPtr& o )
{
attach(o.d); return *this;
}
inline const KisWeakSharedPtr<T>& operator= ( const KisWeakSharedPtr& o ) const {
attach(o.d);
return *this;
......@@ -166,7 +169,7 @@ class KisWeakSharedPtr {
return *this;
}
inline operator const T* () const { Q_ASSERT(dataPtr && dataPtr->valid); return d; }
inline operator const T* () const { Q_ASSERT(not d or( dataPtr and dataPtr->valid)); return d; }
template< class T2> inline operator KisWeakSharedPtr<T2>() const { return KisWeakSharedPtr<T2>(d); }
......@@ -175,26 +178,32 @@ class KisWeakSharedPtr {
* to this pointer are deleted, resulting in a segmentation fault. Use with care.
* @return the pointer
*/
inline T* data() { Q_ASSERT(dataPtr && dataPtr->valid); return d; }
inline T* data() {
Q_ASSERT(not d or( dataPtr and dataPtr->valid));
return d;
}
/**
* Note that if you use this function, the pointer might be destroyed if KisSharedPtr pointing
* to this pointer are deleted, resulting in a segmentation fault. Use with care.
* @return the pointer
*/
inline const T* data() const { Q_ASSERT(dataPtr && dataPtr->valid); return d; }
inline const T* data() const {
Q_ASSERT(not d or( dataPtr and dataPtr->valid));
return d;
}
/**
* Note that if you use this function, the pointer might be destroyed if KisSharedPtr pointing
* to this pointer are deleted, resulting in a segmentation fault. Use with care.
* @return a const pointer to the shared object.
*/
inline const T* constData() const { Q_ASSERT(dataPtr && dataPtr->valid); return d; }
inline const T* constData() const { Q_ASSERT(not d or( dataPtr and dataPtr->valid)); return d; }
inline const T& operator*() const { Q_ASSERT(dataPtr && dataPtr->valid); return *d; }
inline T& operator*() { Q_ASSERT(dataPtr && dataPtr->valid); return *d; }
inline const T* operator->() const { Q_ASSERT(dataPtr && dataPtr->valid); return d; }
inline T* operator->() { Q_ASSERT(dataPtr && dataPtr->valid); return d; }
inline const T& operator*() const { Q_ASSERT(d and dataPtr and dataPtr->valid); return *d; }
inline T& operator*() { Q_ASSERT(d and dataPtr and dataPtr->valid); return *d; }
inline const T* operator->() const { Q_ASSERT(d and dataPtr and dataPtr->valid); return d; }
inline T* operator->() { Q_ASSERT(d and dataPtr and dataPtr->valid); return d; }
/**
* @return true if the pointer is null
......@@ -204,7 +213,7 @@ class KisWeakSharedPtr {
private:
void attach(T* nd)
{
nd = d;
d = nd;
if(d) dataPtr = d->dataPtr;
else dataPtr = 0;
}
......
......@@ -68,7 +68,7 @@ void KisTransaction::redo()
m_private->m_memento->extent(x,y,width,height);
rc.setRect(x + m_private->m_device->getX(), y + m_private->m_device->getY(), width, height);
KisLayer *l = m_private->m_device->parentLayer();
KisLayerSP l = m_private->m_device->parentLayer();
if (l) l->setDirty(rc);
}
......@@ -82,7 +82,7 @@ void KisTransaction::undo()
m_private->m_memento->extent(x,y,width,height);
rc.setRect(x + m_private->m_device->getX(), y + m_private->m_device->getY(), width, height);
KisLayer *l = m_private->m_device->parentLayer();
KisLayerSP l = m_private->m_device->parentLayer();
if (l) l->setDirty(rc);
}
......
......@@ -61,6 +61,7 @@ typedef vKisMaskSP::const_iterator vKisMaskSP_cit;
class KisLayer;
typedef KisSharedPtr<KisLayer> KisLayerSP;
typedef KisWeakSharedPtr<KisLayer> KisLayerWSP;
typedef KisSharedPtrVector<KisLayer> vKisLayerSP;
typedef vKisLayerSP::iterator vKisLayerSP_it;
typedef vKisLayerSP::const_iterator vKisLayerSP_cit;
......@@ -76,6 +77,7 @@ typedef KisSharedPtr<KisAdjustmentLayer> KisAdjustmentLayerSP;
class KisGroupLayer;
typedef KisSharedPtr<KisGroupLayer> KisGroupLayerSP;
typedef KisWeakSharedPtr<KisGroupLayer> KisGroupLayerWSP;
class KisSelection;
typedef KisSharedPtr<KisSelection> KisSelectionSP;
......
......@@ -125,7 +125,7 @@ void KisDropshadow::dropshadow(KisProgressDisplayInterface * progress, qint32 xo
KisGroupLayerSP parent = image->rootLayer();
if (image->activeLayer())
parent = image->activeLayer()->parent().data();
parent = image->activeLayer()->parentLayer().data();
KisPaintLayerSP l = KisPaintLayerSP(new KisPaintLayer(image.data(), i18n("Drop Shadow"), opacity, shadowDev));
image->addLayer( KisLayerSP(l.data()), parent, src->siblingBelow() );
......
......@@ -58,11 +58,11 @@ void KisImportCatcher::slotLoadingFinished()
importedImageLayer->setName(m_url.prettyUrl());
KisGroupLayerSP parent = KisGroupLayerSP( 0 );
KisGroupLayerSP parent = 0;
KisLayerSP currentActiveLayer = m_image->activeLayer();
if (currentActiveLayer) {
parent = currentActiveLayer->parent();
parent = currentActiveLayer->parentLayer();
}
if (parent.isNull()) {
......
......@@ -435,7 +435,7 @@ void KisLayerManager::layerAdd()
{
KisImageSP img = m_view->image();
if (img && img->activeLayer()) {
addLayer(img->activeLayer()->parent(), img->activeLayer());
addLayer(img->activeLayer()->parentLayer(), img->activeLayer());
}
else if (img)
addLayer(img->rootLayer(), KisLayerSP(0));
......@@ -498,7 +498,7 @@ void KisLayerManager::addAdjustmentLayer()
KisImageSP img = m_view->image();
if (!img) return;
addAdjustmentLayer( img->activeLayer()->parent(), img->activeLayer() );
addAdjustmentLayer( img->activeLayer()->parentLayer(), img->activeLayer() );
}
void KisLayerManager::addAdjustmentLayer(KisGroupLayerSP parent, KisLayerSP above)
......@@ -581,8 +581,8 @@ void KisLayerManager::layerRemove()
img->removeLayer(layer);
if (layer->parent())
layer->parent()->setDirty(layer->extent());
if (layer->parentLayer())
layer->parentLayer()->setDirty(layer->extent());
m_view->canvas()->update();
m_view->updateGUI();
......@@ -604,7 +604,7 @@ void KisLayerManager::layerDuplicate()
KisLayerSP dup = active->clone();
dup->setName(i18n("Duplicate of '%1'",active->name()));
img->addLayer(dup, active->parent(), active);
img->addLayer(dup, active->parentLayer(), active);
if (dup) {
img->activateLayer( dup );
m_view->canvas()->update();
......
......@@ -87,7 +87,7 @@ QModelIndex KisLayerModel::indexFromLayer(const KisLayer *layer) const
{
kDebug(41007) << "KisLayer::indexFromLayer " << layer << ", layer index: " << layer->index() << endl;
Q_ASSERT(layer);
if ( layer->parent() )
if ( layer->parentLayer() )
return createIndex(layer->index(), 0, ( void* )layer);
else {
return QModelIndex();
......@@ -146,12 +146,12 @@ QModelIndex KisLayerModel::parent(const QModelIndex &index) const
KisLayer * l = static_cast<KisLayer*>( index.internalPointer() );
kDebug(41007) << " layer: " << l << ", name: " << l->name() << ", parent: " << l->parent() << endl;
KisGroupLayer *p = l->parent().data();
KisGroupLayer *p = l->parentLayer().data();
// If the parent is the root layer, we want to return an invalid
// parent, because the qt model shouldn't know about our root layer.
if ( p && p->parent().data() ) {
kDebug(41007) << "parent layer: " << p << ", name: " << p->name() << ", parent: " << p->parent() << endl;
if ( p && p->parentLayer().data() ) {
kDebug(41007) << "parent layer: " << p << ", name: " << p->name() << ", parent: " << p->parentLayer() << endl;
return indexFromLayer( p );
}
else
......@@ -267,4 +267,37 @@ void KisLayerModel::endRemoveLayers( KisGroupLayer *, int )
endRemoveRows();
}
bool KisLayerModel::dropMimeData ( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent )
{
kDebug(41007) << "KisLayerModel::dropMimeData" << endl;
kDebug(41007) << "KisLayerModel::dropMimeData " << data->formats() << endl;
const QString format = "application/x-qabstractitemmodeldatalist";
if(not data->hasFormat( format ))
{
return false;
}
QByteArray encoded = data->data(format);
QDataStream stream(&encoded, QIODevice::ReadOnly);
if(action == Qt::CopyAction)
{
kDebug(41007) << "KisLayerModel::dropMimeData copy action" << endl;
while (!stream.atEnd()) {
int r, c;
QMap<int, QVariant> v;
stream >> r >> c >> v;
kDebug(41007) << "KisLayerModel::dropMimeData copy action " << r << " " << c << endl;
}
return true;
} else if(action == Qt::MoveAction) {
kDebug(41007) << "KisLayerModel::dropMimeData move action" << endl;
return true;
}
return false;
}
Qt::DropActions KisLayerModel::supportedDragActions () const
{
return Qt::CopyAction | Qt::MoveAction;
}
#include "kis_layer_model.moc"
......@@ -44,15 +44,18 @@ public: // from QAbstractItemModel
KisLayerSP layerFromIndex(const QModelIndex &index);
vKisLayerSP layersFromIndexes(const QModelIndexList &list);
QModelIndex indexFromLayer(const KisLayer *layer) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
virtual QModelIndex indexFromLayer(const KisLayer *layer) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
virtual QModelIndex parent(const QModelIndex &index) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
virtual bool dropMimeData ( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent );
virtual Qt::DropActions supportedDragActions () const;
public slots:
void beginInsertLayers( KisGroupLayer * parent, int index );
......
......@@ -197,7 +197,7 @@ void KisLayerBox::updateUI()
kDebug(41007) << "###### KisLayerBox::updateUI " << m_image->activeLayer() << endl;
bnDelete->setEnabled(m_image->activeLayer());
bnRaise->setEnabled(m_image->activeLayer() && (m_image->activeLayer()->prevSibling() || m_image->activeLayer()->parent()));
bnRaise->setEnabled(m_image->activeLayer() && (m_image->activeLayer()->prevSibling() || m_image->activeLayer()->parentLayer()));
bnLower->setEnabled(m_image->activeLayer() && m_image->activeLayer()->nextSibling());
doubleOpacity->setEnabled(m_image->activeLayer());
cmbComposite->setEnabled(m_image->activeLayer());
......@@ -287,8 +287,8 @@ void KisLayerBox::getNewLayerLocation(KisGroupLayerSP &parent, KisLayerSP &above
{
parent = root;
above = active;
if (active->parent())
parent = active->parent();
if (active->parentLayer())
parent = active->parentLayer();
}
}
else
......@@ -341,17 +341,17 @@ void KisLayerBox::slotRaiseClicked()
QModelIndexList l = selectedLayers();
KisLayerSP layer = m_layerModel->layerFromIndex(l.first());
if( l.count() == 1 && layer == layer->parent()->firstChild() && layer->parent() != m_image->rootLayer())
if( l.count() == 1 && layer == layer->parentLayer()->firstChild() && layer->parentLayer() != m_image->rootLayer())
{
if (KisGroupLayerSP grandparent = layer->parent()->parent())
m_image->moveLayer(layer, grandparent, KisLayerSP(layer->parent().data()));
if (KisGroupLayerSP grandparent = layer->parentLayer()->parentLayer())
m_image->moveLayer(layer, grandparent, KisLayerSP(layer->parentLayer().data()));
}
else
{
for (int i = 0, n = l.count(); i < n; ++i)
if (KisLayerSP li = m_layerModel->layerFromIndex(l[i]))
if (li->prevSibling())
m_image->moveLayer(li, li->parent(), li->prevSibling());
m_image->moveLayer(li, li->parentLayer(), li->prevSibling());
}
if( !l.isEmpty() )
......@@ -367,9 +367,9 @@ void KisLayerBox::slotLowerClicked()
if (layer->nextSibling())
{
if (layer->nextSibling()->nextSibling())
m_image->moveLayer(layer, layer->parent(), layer->nextSibling()->nextSibling());
m_image->moveLayer(layer, layer->parentLayer(), layer->nextSibling()->nextSibling());
else
m_image->moveLayer(layer, layer->parent(), KisLayerSP(0));
m_image->moveLayer(layer, layer->parentLayer(), KisLayerSP(0));
}
if( !l.isEmpty() )
......
......@@ -70,11 +70,13 @@ public:
bool visit(KisPaintLayer *layer)
{
// kDebug(41007) << "KisLayerMap visitor adding paint layer: " << layer->name() << endl;
Q_ASSERT( m_layerMap.contains( layer->parent() ) );
kDebug() << layer << " " << layer->parentLayer().data() << endl;
Q_ASSERT( layer->parentLayer() );
Q_ASSERT( m_layerMap.contains( layer->parentLayer() ) );
if ( m_layerMap.contains( layer->parent() ) ) {
if ( m_layerMap.contains( layer->parentLayer() ) ) {
KoShapeContainer * parent = static_cast<KoShapeContainer*>( m_layerMap[layer->parent()] );
KoShapeContainer * parent = static_cast<KoShapeContainer*>( m_layerMap[layer->parentLayer()] );
KisLayerShape * layerShape = new KisLayerShape( parent, layer );
m_layerMap[layer] = layerShape;
......@@ -88,8 +90,8 @@ public:
// kDebug(41007) << "KisLayerMap visitor adding group layer: " << layer->name() << endl;
KoShapeContainer * parent = 0;
if ( m_layerMap.contains( layer->parent() ) ) {