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 8e3f993a authored by Emmet O'Neill's avatar Emmet O'Neill

Fixed bad assertion and failure to undo removeAllAssistants.

KisAssistantTool::removeAllAssistants function wasn't making correct use
of EditAssistantsCommand. EditAssistantsCommand also contained a flawed and
unnecessary assertion.

Thanks for the help Eoin.

BUG:419189
parent e9f34a0e
......@@ -51,27 +51,26 @@ EditAssistantsCommand::EditAssistantsCommand(QPointer<KisCanvas2> canvas, Assist
KIS_ASSERT_RECOVER_RETURN(type != EDIT);
}
void EditAssistantsCommand::replaceWith(AssistantSPList assistants, Type type)
void EditAssistantsCommand::replaceWith(AssistantSPList newAssistants, Type type)
{
AssistantSPList curAssistants = m_canvas->paintingAssistantsDecoration()->assistants();
if (type == EDIT) {
KIS_ASSERT_RECOVER_RETURN(curAssistants.size() == assistants.size());
} else if (type == ADD) {
KIS_ASSERT_RECOVER_RETURN(curAssistants.size() == assistants.size() - 1);
} else { // type == REMOVE
KIS_ASSERT_RECOVER_RETURN(curAssistants.size() == assistants.size() + 1);
AssistantSPList oldAssistants = m_canvas->paintingAssistantsDecoration()->assistants();
if (type == ADD) {
KIS_ASSERT_RECOVER_RETURN(newAssistants.size() > oldAssistants.size());
} else if (type == REMOVE) {
KIS_ASSERT_RECOVER_RETURN(newAssistants.size() < oldAssistants.size());
}
Q_FOREACH (KisPaintingAssistantSP assistant, curAssistants) {
Q_FOREACH (KisPaintingAssistantSP assistant, oldAssistants) {
KisAbstractPerspectiveGrid* grid = dynamic_cast<KisAbstractPerspectiveGrid*>(assistant.data());
if (grid) {
m_canvas->viewManager()->canvasResourceProvider()->removePerspectiveGrid(grid);
}
}
m_canvas->paintingAssistantsDecoration()->setAssistants(assistants);
m_canvas->paintingAssistantsDecoration()->setAssistants(newAssistants);
Q_FOREACH (KisPaintingAssistantSP assistant, assistants) {
Q_FOREACH (KisPaintingAssistantSP assistant, newAssistants) {
assistant->uncache();
KisAbstractPerspectiveGrid* grid = dynamic_cast<KisAbstractPerspectiveGrid*>(assistant.data());
if (grid) {
......
......@@ -719,8 +719,14 @@ void KisAssistantTool::paint(QPainter& _gc, const KoViewConverter &_converter)
void KisAssistantTool::removeAllAssistants()
{
m_origAssistantList = m_canvas->paintingAssistantsDecoration()->assistants();
m_canvas->viewManager()->canvasResourceProvider()->clearPerspectiveGrids();
m_canvas->paintingAssistantsDecoration()->removeAll();
KUndo2Command *removeAssistantCmd = new EditAssistantsCommand(m_canvas, m_origAssistantList, KisPaintingAssistant::cloneAssistantList(m_canvas->paintingAssistantsDecoration()->assistants()));
m_canvas->viewManager()->undoAdapter()->addCommand(removeAssistantCmd);
m_handles = m_canvas->paintingAssistantsDecoration()->handles();
m_canvas->updateCanvas();
......@@ -961,11 +967,8 @@ QWidget *KisAssistantTool::createOptionWidget()
connect(m_options.assistantsColor, SIGNAL(changed(QColor)), SLOT(slotGlobalAssistantsColorChanged(QColor)));
connect(m_options.assistantsGlobalOpacitySlider, SIGNAL(valueChanged(int)), SLOT(slotGlobalAssistantOpacityChanged()));
connect(m_options.vanishingPointAngleSpinbox, SIGNAL(valueChanged(double)), this, SLOT(slotChangeVanishingPointAngle(double)));
//ENTER_FUNCTION() << ppVar(m_canvas) << ppVar(m_canvas && m_canvas->paintingAssistantsDecoration());
// initialize UI elements with existing data if possible
if (m_canvas && m_canvas->paintingAssistantsDecoration()) {
const QColor color = m_canvas->paintingAssistantsDecoration()->globalAssistantsColor();
......@@ -973,8 +976,6 @@ QWidget *KisAssistantTool::createOptionWidget()
QColor opaqueColor = color;
opaqueColor.setAlpha(255);
//ENTER_FUNCTION() << ppVar(opaqueColor);
m_options.assistantsColor->setColor(opaqueColor);
m_options.customAssistantColorButton->setColor(opaqueColor);
m_options.assistantsGlobalOpacitySlider->setValue(color.alphaF() * 100.0);
......
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