Merge branch 'fix-2564'

This commit is contained in:
David Capello 2021-01-04 15:55:50 -03:00
commit 4b1e4c67c5
4 changed files with 23 additions and 6 deletions

View File

@ -32,6 +32,7 @@
#include "doc/palette.h"
#include "doc/sprite.h"
#include "doc/tag.h"
#include "doc/slice.h"
#include "os/display.h"
#include "os/system.h"
#include "ui/system.h"
@ -511,6 +512,14 @@ Doc* Doc::duplicate(DuplicateType type) const
for (const Tag* tag : sourceSprite->tags())
spriteCopy->tags().add(new Tag(*tag));
// Copy slices
for (const Slice *slice : sourceSprite->slices()) {
auto sliceCopy = new Slice(*slice);
spriteCopy->slices().add(sliceCopy);
ASSERT(sliceCopy->owner() == &spriteCopy->slices());
}
// Copy color palettes
{
PalettesList::const_iterator it = sourceSprite->getPalettes().begin();

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

@ -41,6 +41,14 @@ Slice::Slice()
{
}
Slice::Slice(const Slice& other)
: WithUserData(other)
, m_owner(nullptr)
, m_name(other.m_name)
, m_keys(other.m_keys)
{
}
Slice::~Slice()
{
ASSERT(!m_owner);

View File

@ -54,6 +54,7 @@ namespace doc {
typedef List::const_iterator const_iterator;
Slice();
Slice(const Slice& other);
~Slice();
int getMemSize() const override;
@ -88,8 +89,6 @@ namespace doc {
Slices* m_owner;
std::string m_name;
List m_keys;
DISABLE_COPYING(Slice);
};
} // namespace doc