Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix pasting clips which are out-of-bounds of the image

Dmitry Kazakov435dd4989f61
diff --git a/libs/ui/kis_mimedata.cpp b/libs/ui/kis_mimedata.cpp
index 7a73f24089..90372bab7d 100644
--- a/libs/ui/kis_mimedata.cpp
+++ b/libs/ui/kis_mimedata.cpp
@@ -599,24 +599,26 @@ bool KisMimeData::insertMimeLayers(const QMimeData *data,
{
QList<KisNodeSP> nodes = loadNodesFast(data, image, shapeController, copyNode /* IN-OUT */);
+ const QRect clipVisualBounds = std::accumulate(nodes.begin(), nodes.end(), QRect(), [](QRect rect, KisNodeSP node) {
+ // we don't use exactBounds() here, because the nodes are
+ // not connected to any image and may be infinite
+ return rect | node->projection()->nonDefaultPixelArea();
+ });
+
QRect clipBounds;
if (const KisMimeData *mimedata = qobject_cast<const KisMimeData*>(data)) {
clipBounds = mimedata->m_referenceRect;
} else {
- clipBounds = std::accumulate(nodes.begin(), nodes.end(), QRect(), [](QRect rect, KisNodeSP node) {
- // we don't use exactBounds() here, because the nodes are
- // not connected to any image and may be infinite
- return rect | node->projection()->nonDefaultPixelArea();
- });
+ clipBounds = clipVisualBounds;
}
std::optional<QPoint> offset;
if (preferredClipCenter) {
offset = *preferredClipCenter - clipBounds.center();
- } else if (!image->bounds().intersects(clipBounds)) {
- offset = image->bounds().center() - clipBounds.center();
+ } else if (!image->bounds().intersects(clipVisualBounds)) {
+ offset = image->bounds().center() - clipVisualBounds.center();
}
if (offset) {