Commit bcb16568 authored by Cyrille Berger's avatar Cyrille Berger

Backport Fix: crashed when using the draw path tool on a shape layer.

BUG: 190877

svn path=/branches/koffice/2.0/koffice/; revision=960613
parent 9bd923fa
......@@ -26,6 +26,8 @@
#include "kis_image.h"
#include "kis_painter.h"
#include "kis_layer.h"
#include "canvas/kis_canvas2.h"
#include "kis_view2.h"
#include "kis_canvas_resource_provider.h"
#include "kis_paintop_registry.h"
#include "kis_selection.h"
......@@ -43,17 +45,21 @@ void KisToolPath::addPathShape()
{
KisNodeSP currentNode =
m_canvas->resourceProvider()->resource(KisCanvasResourceProvider::CurrentKritaNode).value<KisNodeSP>();
if (!currentNode)
if (!currentNode || !currentNode->paintDevice()) {
delete m_shape;
m_shape = 0;
return;
}
KisImageSP image = qobject_cast<KisLayer*>(currentNode->parent().data())->image();
KisPaintDeviceSP dev = currentNode->paintDevice();
KisSelectionSP selection = image->globalSelection();
// XXX: also get global selection!
if (selection && currentNode->inherits("KisLayer")) {
selection = qobject_cast<KisLayer*>(currentNode.data())->selection();
}
KisCanvas2 *canvas = dynamic_cast<KisCanvas2 *>(m_canvas);
if(!canvas)
return;
KisImageSP image = canvas->view()->image();
KisSelectionSP selection = canvas->view()->selection();
KisPainter painter(dev, selection);
painter.beginTransaction(i18n("Path"));
painter.setPaintColor(KoColor(Qt::black, dev->colorSpace()));
......
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