Commit ed6d84ce authored by Sven Langkamp's avatar Sven Langkamp
Browse files

fix crash on painting after changing colorspace, tool was still storing the old composite op

BUG:274874
parent 712b2abc
......@@ -125,7 +125,7 @@ bool KisToolFill::flood(int startX, int startY)
m_painter->beginTransaction(i18n("Fill"));
m_painter->setCompositeOp(m_compositeOp);
m_painter->setCompositeOp(compositeOp());
m_painter->setOpacity(m_opacity);
foreach(const QRect &rc, dirty) {
......@@ -143,7 +143,7 @@ bool KisToolFill::flood(int startX, int startY)
fillPainter.setProgress(updater->startSubtask());
fillPainter.setOpacity(m_opacity);
fillPainter.setFillThreshold(m_threshold);
fillPainter.setCompositeOp(m_compositeOp);
fillPainter.setCompositeOp(compositeOp());
fillPainter.setSampleMerged(!m_unmerged);
fillPainter.setCareForSelection(true);
fillPainter.setWidth(currentImage()->width());
......
......@@ -523,8 +523,9 @@ void KisToolMultihand::initPaint(KoPointerEvent *)
KisPaintDeviceSP paintDevice = currentNode()->paintDevice();
KisPaintDeviceSP targetDevice;
if (!m_compositeOp)
m_compositeOp = paintDevice->colorSpace()->compositeOp(COMPOSITE_OVER);
const KoCompositeOp* op = compositeOp();
if (!op)
op = paintDevice->colorSpace()->compositeOp(COMPOSITE_OVER);
m_strokeTimeMeasure.start();
m_paintIncremental = currentPaintOpPreset()->settings()->paintIncremental();
......@@ -536,7 +537,7 @@ void KisToolMultihand::initPaint(KoPointerEvent *)
if (indirect) {
targetDevice = new KisPaintDevice(currentNode().data(), paintDevice->colorSpace());
indirect->setTemporaryTarget(targetDevice);
indirect->setTemporaryCompositeOp(m_compositeOp);
indirect->setTemporaryCompositeOp(op);
indirect->setTemporaryOpacity(m_opacity);
}
else {
......@@ -554,7 +555,7 @@ void KisToolMultihand::initPaint(KoPointerEvent *)
KisPainter * painter = new KisPainter(targetDevice, currentSelection());
setupPainter(painter);
if (m_paintIncremental) {
painter->setCompositeOp(m_compositeOp);
painter->setCompositeOp(op);
painter->setOpacity(m_opacity);
} else {
painter->setCompositeOp(paintDevice->colorSpace()->compositeOp(COMPOSITE_ALPHA_DARKEN));
......
......@@ -355,8 +355,9 @@ void KisToolFreehand::initPaint(KoPointerEvent *)
KisPaintDeviceSP paintDevice = currentNode()->paintDevice();
KisPaintDeviceSP targetDevice;
if (!m_compositeOp)
m_compositeOp = paintDevice->colorSpace()->compositeOp(COMPOSITE_OVER);
const KoCompositeOp* op = compositeOp();
if (!op)
op = paintDevice->colorSpace()->compositeOp(COMPOSITE_OVER);
m_strokeTimeMeasure.start();
m_paintIncremental = currentPaintOpPreset()->settings()->paintIncremental();
......@@ -368,7 +369,7 @@ void KisToolFreehand::initPaint(KoPointerEvent *)
if (indirect) {
targetDevice = new KisPaintDevice(currentNode().data(), paintDevice->colorSpace());
indirect->setTemporaryTarget(targetDevice);
indirect->setTemporaryCompositeOp(m_compositeOp);
indirect->setTemporaryCompositeOp(op);
indirect->setTemporaryOpacity(m_opacity);
KisPaintLayer* paintLayer = dynamic_cast<KisPaintLayer*>(currentNode().data());
......@@ -394,7 +395,7 @@ void KisToolFreehand::initPaint(KoPointerEvent *)
setupPainter(m_painter);
if (m_paintIncremental) {
m_painter->setCompositeOp(m_compositeOp);
m_painter->setCompositeOp(compositeOp());
m_painter->setOpacity(m_opacity);
} else {
m_painter->setCompositeOp(paintDevice->colorSpace()->compositeOp(COMPOSITE_ALPHA_DARKEN));
......
......@@ -78,7 +78,6 @@ KisToolPaint::KisToolPaint(KoCanvasBase * canvas, const QCursor & cursor)
m_optionWidgetLayout = 0;
m_opacity = OPACITY_OPAQUE_U8;
m_compositeOp = 0;
updateTabletPressureSamples();
......@@ -96,8 +95,6 @@ KisToolPaint::KisToolPaint(KoCanvasBase * canvas, const QCursor & cursor)
connect(m_darkerColor, SIGNAL(activated()), SLOT(makeColorDarker()));
addAction("make_brush_color_darker", m_darkerColor);
connect(kiscanvas->view()->resourceProvider(), SIGNAL(sigCompositeOpChanged(QString)), this, SLOT(slotSetCompositeMode(QString)));
connect(this, SIGNAL(sigFavoritePaletteCalled(const QPoint&)), kiscanvas, SIGNAL(favoritePaletteCalled(const QPoint&)));
connect(this, SIGNAL(sigPaintingFinished()), kiscanvas->view()->resourceProvider(), SLOT(slotPainting()));
}
......@@ -117,9 +114,6 @@ void KisToolPaint::resourceChanged(int key, const QVariant& v)
KisTool::resourceChanged(key, v);
switch(key){
case(KisCanvasResourceProvider::CurrentKritaNode):
slotSetCompositeMode(canvas()->resourceManager()->resource(KisCanvasResourceProvider::CurrentCompositeOp).toString());
break;
case(KisCanvasResourceProvider::Opacity):
slotSetOpacity(v.toDouble());
break;
......@@ -137,7 +131,6 @@ void KisToolPaint::activate(ToolActivation toolActivation, const QSet<KoShape*>
{
KisTool::activate(toolActivation, shapes);
KisCanvas2 * kiscanvas = static_cast<KisCanvas2*>(canvas());
slotSetCompositeMode(kiscanvas->view()->resourceProvider()->currentCompositeOp());
resetCursorStyle();
}
......@@ -327,16 +320,16 @@ void KisToolPaint::slotSetOpacity(qreal opacity)
m_opacity = quint8(opacity * OPACITY_OPAQUE_U8);
}
void KisToolPaint::slotSetCompositeMode(const QString& compositeOp)
const KoCompositeOp* KisToolPaint::compositeOp()
{
Q_ASSERT(!compositeOp.isEmpty());
if (currentNode()) {
KisPaintDeviceSP device = currentNode()->paintDevice();
if (device) {
m_compositeOp = device->colorSpace()->compositeOp(compositeOp);
QString op = canvas()->resourceManager()->resource(KisCanvasResourceProvider::CurrentCompositeOp).toString();
return device->colorSpace()->compositeOp(op);
}
}
return 0;
}
void KisToolPaint::slotPopupQuickHelp()
......@@ -389,7 +382,7 @@ void KisToolPaint::setupPainter(KisPainter* painter)
{
KisTool::setupPainter(painter);
painter->setOpacity(m_opacity);
painter->setCompositeOp(m_compositeOp);
painter->setCompositeOp(compositeOp());
QPointF axisCenter = canvas()->resourceManager()->resource(KisCanvasResourceProvider::MirrorAxisCenter).toPointF();
if (axisCenter.isNull()){
......@@ -404,8 +397,9 @@ void KisToolPaint::setupPaintAction(KisRecordedPaintAction* action)
{
KisTool::setupPaintAction(action);
action->setOpacity(m_opacity / qreal(255.0));
if (m_compositeOp) {
action->setCompositeOp(m_compositeOp->id());
const KoCompositeOp* op = compositeOp();
if (op) {
action->setCompositeOp(op->id());
}
}
......
......@@ -129,6 +129,7 @@ protected:
/// Checks if and how the tool can paint on the current node
NodePaintAbility nodePaintAbility();
const KoCompositeOp* compositeOp();
public slots:
virtual void activate(ToolActivation toolActivation, const QSet<KoShape*> &shapes);
......@@ -138,7 +139,6 @@ private slots:
void slotPopupQuickHelp();
void slotSetOpacity(qreal opacity);
void slotSetCompositeMode(const QString& compositeOp);
void makeColorLighter();
void makeColorDarker();
......@@ -149,7 +149,6 @@ protected slots:
protected:
quint8 m_opacity;
const KoCompositeOp * m_compositeOp;
bool m_paintOutline;
QVector<qreal> m_pressureSamples;
......
Supports Markdown
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