Commit 27a98261 authored by Stefano Bonicatti's avatar Stefano Bonicatti

KisGroupLayer memory leak fix and KisPaintLayer retain fix

Don't track null shared pointer created with the assignment operator.

Changed a couple of shared pointers to weak pointers so that the UI avoids retaining
layers.
parent f107db5a
......@@ -140,7 +140,10 @@ KisMemoryLeakTracker::~KisMemoryLeakTracker()
void KisMemoryLeakTracker::reference(const void* what, const void* bywho, const char* whatName)
{
if(what == 0x0) return;
QMutexLocker l(&d->m);
if (whatName == 0 || ( strcmp(whatName, "PK13KisSharedData") != 0
#ifdef IGNORE_MEMENTO_ITEM
&& strcmp(whatName, "PK14KisMementoItem") != 0
......
......@@ -316,4 +316,6 @@ private:
Q_DECLARE_METATYPE(KisNodeSP)
Q_DECLARE_METATYPE(KisNodeWSP)
#endif
......@@ -392,11 +392,13 @@ void KisLayerBox::unsetCanvas()
m_newLayerMenu->clear();
}
setCanvas(0);
m_nodeManager->setSelectedNodes(QList<KisNodeSP>());
}
void KisLayerBox::notifyImageDeleted()
{
setCanvas(0);
m_nodeManager->setSelectedNodes(QList<KisNodeSP>());
}
void KisLayerBox::updateUI()
......
......@@ -80,7 +80,11 @@ KisShapeController::KisShapeController(KisDocument *doc, KisNameServer *nameServ
KisShapeController::~KisShapeController()
{
//setImage(0);
KisNodeDummy *node = m_d->shapesGraph.rootDummy();
if (node) {
m_d->shapesGraph.removeNode(node->node());
}
delete m_d;
}
......
......@@ -263,7 +263,7 @@ void KisCanvasResourceProvider::slotSetBGColor(const KoColor& c)
void KisCanvasResourceProvider::slotNodeActivated(const KisNodeSP node)
{
QVariant v;
v.setValue(node);
v.setValue(KisNodeWSP(node));
m_resourceManager->setResource(CurrentKritaNode, v);
emit sigNodeChanged(currentNode());
}
......
......@@ -718,7 +718,7 @@ void KisPaintopBox::slotSetupDefaultPreset()
void KisPaintopBox::slotNodeChanged(const KisNodeSP node)
{
if (m_previousNode && m_previousNode->paintDevice())
if (m_previousNode.isValid() && m_previousNode->paintDevice())
disconnect(m_previousNode->paintDevice().data(), SIGNAL(colorSpaceChanged(const KoColorSpace*)), this, SLOT(slotColorSpaceChanged(const KoColorSpace*)));
// Reconnect colorspace change of node
......
......@@ -189,7 +189,7 @@ private:
QString m_prevCompositeOpID;
QString m_currCompositeOpID;
KisNodeSP m_previousNode;
KisNodeWSP m_previousNode;
QPalette palette;
QPalette palette_highlight;
......
......@@ -409,7 +409,7 @@ KisPaintOpPresetSP KisTool::currentPaintOpPreset()
KisNodeSP KisTool::currentNode()
{
KisNodeSP node = canvas()->resourceManager()->resource(KisCanvasResourceProvider::CurrentKritaNode).value<KisNodeSP>();
KisNodeSP node = canvas()->resourceManager()->resource(KisCanvasResourceProvider::CurrentKritaNode).value<KisNodeWSP>();
return node;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment