Commit 2b617387 authored by Ashwin  Dhakaita's avatar Ashwin Dhakaita Committed by Boudewijn Rempt

Fix crash when using the transform tool on a colorize mask

This fixes a crash when the transform tool is selected while
using a colorize mask in the layer stack with edit-key-strokes
option set to OFF.

Differential Revision:  https://phabricator.kde.org/D19906
BUG: 404759
parent 94292309
......@@ -524,6 +524,25 @@ void KisTool::deleteSelection()
}
}
KisTool::NodePaintAbility KisTool::nodePaintAbility()
{
KisNodeSP node = currentNode();
if (!node) {
return NodePaintAbility::UNPAINTABLE;
}
if (node->inherits("KisShapeLayer")) {
return NodePaintAbility::VECTOR;
}
if (node->inherits("KisCloneLayer")) {
return NodePaintAbility::CLONE;
}
if (node->paintDevice()) {
return NodePaintAbility::PAINT;
}
return NodePaintAbility::UNPAINTABLE;
}
QWidget* KisTool::createOptionWidget()
{
d->optionWidget = new QLabel(i18n("No options"));
......
......@@ -161,6 +161,14 @@ public:
NONE = 10000
};
enum NodePaintAbility {
VECTOR,
CLONE,
PAINT,
UNPAINTABLE
};
Q_ENUMS(NodePaintAbility)
static AlternateAction actionToAlternateAction(ToolAction action);
virtual void activateAlternateAction(AlternateAction action);
......@@ -180,6 +188,8 @@ public:
bool isActive() const;
KisTool::NodePaintAbility nodePaintAbility();
public Q_SLOTS:
void activate(ToolActivation activation, const QSet<KoShape*> &shapes) override;
void deactivate() override;
......
......@@ -597,24 +597,6 @@ void KisToolPaint::slotPopupQuickHelp()
QWhatsThis::showText(QCursor::pos(), quickHelp());
}
KisToolPaint::NodePaintAbility KisToolPaint::nodePaintAbility()
{
KisNodeSP node = currentNode();
if (!node) {
return NONE;
}
if (node->inherits("KisShapeLayer")) {
return VECTOR;
}
if (node->inherits("KisCloneLayer")) {
return CLONE;
}
if (node->paintDevice()) {
return PAINT;
}
return NONE;
}
void KisToolPaint::activatePrimaryAction()
{
pickColorWasOverridden();
......
......@@ -110,16 +110,6 @@ protected:
return QString();
}
enum NodePaintAbility {
NONE,
PAINT,
VECTOR,
CLONE
};
/// Checks if and how the tool can paint on the current node
NodePaintAbility nodePaintAbility();
const KoCompositeOp* compositeOp();
public Q_SLOTS:
......
......@@ -79,7 +79,7 @@ void KisToolPolylineBase::beginPrimaryAction(KoPointerEvent *event)
{
Q_UNUSED(event);
if ((m_type == PAINT && (!nodeEditable() || nodePaintAbility() == NONE)) ||
if ((m_type == PAINT && (!nodeEditable() || nodePaintAbility() == UNPAINTABLE)) ||
(m_type == SELECT && !selectionEditable())) {
event->ignore();
......
......@@ -109,7 +109,7 @@ bool KisToolRectangleBase::listeningToModifiers()
void KisToolRectangleBase::beginPrimaryAction(KoPointerEvent *event)
{
if ((m_type == PAINT && (!nodeEditable() || nodePaintAbility() == NONE)) ||
if ((m_type == PAINT && (!nodeEditable() || nodePaintAbility() == UNPAINTABLE)) ||
(m_type == SELECT && !selectionEditable())) {
event->ignore();
......
......@@ -172,7 +172,7 @@ void KisToolLine::paint(QPainter& gc, const KoViewConverter &converter)
void KisToolLine::beginPrimaryAction(KoPointerEvent *event)
{
NodePaintAbility nodeAbility = nodePaintAbility();
if (nodeAbility == NONE || !nodeEditable()) {
if (nodeAbility == UNPAINTABLE || !nodeEditable()) {
event->ignore();
return;
}
......@@ -263,7 +263,7 @@ void KisToolLine::endStroke()
{
NodePaintAbility nodeAbility = nodePaintAbility();
if (!m_strokeIsRunning || m_startPoint == m_endPoint || nodeAbility == NONE) {
if (!m_strokeIsRunning || m_startPoint == m_endPoint || nodeAbility == UNPAINTABLE) {
return;
}
......
......@@ -859,6 +859,18 @@ void KisToolTransform::startStroke(ToolTransformArgs::TransformMode mode, bool f
* stroke and pass it to the tool somehow. But currently, we will
* just disable starting a new stroke asynchronously
*/
if(nodePaintAbility() == NodePaintAbility::UNPAINTABLE) {
KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
kisCanvas->viewManager()->
showFloatingMessage(
i18nc("floating message in transformation tool",
"Unable to transform the layer"),
QIcon(), 4000, KisFloatingMessage::High);
return;
}
if (image()->tryBarrierLock()) {
image()->unlock();
} else {
......
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