Commit 5b8660d2 authored by Ivan Yossi's avatar Ivan Yossi 👌

Fix copy/paste frames to clipboard

This does not work if source was closed inbetween operations or
source is in another krita instance.

BUG:408421
BUG:404595
parent 2aaa21f8
......@@ -50,7 +50,10 @@
#include "kis_node_view_color_scheme.h"
#include "krita_utils.h"
#include "KisPart.h"
#include <QApplication>
#include "KisDocument.h"
#include "KisViewManager.h"
#include "kis_processing_applicator.h"
#include <KisImageBarrierLockerWithFeedback.h>
#include "kis_node_uuid_info.h"
......@@ -582,6 +585,10 @@ QMimeData *TimelineFramesModel::mimeDataExtended(const QModelIndexList &indexes,
const int baseRow = baseIndex.row();
const int baseColumn = baseIndex.column();
const QByteArray uuidDataRoot = m_d->image->root()->uuid().toRfc4122();
stream << int(uuidDataRoot.size());
stream.writeRawData(uuidDataRoot.data(), uuidDataRoot.size());
stream << indexes.size();
stream << baseRow << baseColumn;
......@@ -639,6 +646,32 @@ bool TimelineFramesModel::dropMimeDataExtended(const QMimeData *data, Qt::DropAc
QByteArray encoded = data->data("application/x-krita-frame");
QDataStream stream(&encoded, QIODevice::ReadOnly);
int uuidLenRoot = 0;
stream >> uuidLenRoot;
QByteArray uuidDataRoot(uuidLenRoot, '\0');
stream.readRawData(uuidDataRoot.data(), uuidLenRoot);
QUuid nodeUuidRoot = QUuid::fromRfc4122(uuidDataRoot);
KisPart *partInstance = KisPart::instance();
QList<QPointer<KisDocument>> documents = partInstance->documents();
KisImageSP srcImage = 0;
Q_FOREACH(KisDocument *doc, documents) {
KisImageSP tmpSrcImage = doc->image();
if (tmpSrcImage->root()->uuid() == nodeUuidRoot) {
srcImage = tmpSrcImage;
break;
}
}
if (!srcImage) {
KisPart *kisPartInstance = KisPart::instance();
kisPartInstance->currentMainwindow()->viewManager()->showFloatingMessage(
i18n("Dropped frames are not avialable in this krita instance")
, QIcon());
return false;
}
int size, baseRow, baseColumn;
stream >> size >> baseRow >> baseColumn;
......@@ -663,7 +696,7 @@ bool TimelineFramesModel::dropMimeDataExtended(const QMimeData *data, Qt::DropAc
if (!nodeUuid.isNull()) {
KisNodeUuidInfo nodeInfo(nodeUuid);
srcNode = nodeInfo.findNode(m_d->image->root());
srcNode = nodeInfo.findNode(srcImage->root());
} else {
QModelIndex index = this->index(srcRow, srcColumn);
srcNode = nodeAt(index);
......
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