Don't generate new slice keyframes when duplicating the sprite (duplicate only the slice keyframes)

Related to #2568
This commit is contained in:
David Capello 2021-01-04 15:52:56 -03:00
parent 25ca9e4a13
commit 23559a9b44
3 changed files with 9 additions and 11 deletions

View File

@ -515,12 +515,9 @@ Doc* Doc::duplicate(DuplicateType type) const
// Copy slices
for (const Slice *slice : sourceSprite->slices()) {
auto sliceCopy = new Slice(*slice);
sliceCopy->setUserData(slice->userData());
for (frame_t i(0); i < sourceSprite->totalFrames(); ++i)
sliceCopy->insert(i, *slice->getByFrame(i));
spriteCopy->slices().add(sliceCopy);
ASSERT(sliceCopy->owner() == &spriteCopy->slices());
}
// Copy color palettes

View File

@ -8,7 +8,6 @@
#define DOC_KEYFRAMES_H_INCLUDED
#pragma once
#include "base/disable_copying.h"
#include "doc/frame.h"
#include <vector>
@ -111,6 +110,11 @@ namespace doc {
Keyframes() { }
Keyframes(const Keyframes& other) {
for (const auto& key : other.m_keys)
m_keys.push_back(Key(key.frame(), new T(*key.value())));
}
void insert(const frame_t frame, T* value) {
auto it = getIterator(frame);
if (it == end())
@ -189,9 +193,6 @@ namespace doc {
private:
List m_keys;
// Disable operator=
DISABLE_COPYING(Keyframes);
};
} // namespace doc

View File

@ -42,13 +42,13 @@ Slice::Slice()
}
Slice::Slice(const Slice& other)
: WithUserData(ObjectType::Slice)
: WithUserData(other)
, m_owner(nullptr)
, m_name(other.m_name)
, m_keys(other.m_keys)
{
}
Slice::~Slice()
{
ASSERT(!m_owner);