Commit a38cef83 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Port clear selection to strokes framework

Otherwise, there is a deadlock

BUG:408843
parent d89fbec1
......@@ -26,6 +26,8 @@
#include <kis_properties_configuration.h>
#include <kconfiggroup.h>
#include <ksharedconfig.h>
#include "kis_command_utils.h"
#include "kis_processing_applicator.h"
namespace KisToolUtils {
......@@ -135,24 +137,26 @@ namespace KisToolUtils {
bool clearImage(KisImageSP image, KisNodeSP node, KisSelectionSP selection)
{
if(node && node->hasEditablePaintDevice()) {
KisPaintDeviceSP device = node->paintDevice();
image->barrierLock();
KisTransaction transaction(kundo2_i18n("Clear"), device);
QRect dirtyRect;
if (selection) {
dirtyRect = selection->selectedRect();
device->clearSelection(selection);
}
else {
dirtyRect = device->extent();
device->clear();
}
transaction.commit(image->undoAdapter());
device->setDirty(dirtyRect);
image->unlock();
KUndo2Command *cmd =
new KisCommandUtils::LambdaCommand(kundo2_i18n("Clear"),
[node, selection] () {
KisPaintDeviceSP device = node->paintDevice();
KisTransaction transaction(kundo2_noi18n("internal-clear-command"), device);
QRect dirtyRect;
if (selection) {
dirtyRect = selection->selectedRect();
device->clearSelection(selection);
} else {
dirtyRect = device->extent();
device->clear();
}
device->setDirty(dirtyRect);
return transaction.endAndTake();
});
KisProcessingApplicator::runSingleCommandStroke(image, cmd);
return true;
}
return false;
......
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