DIRECTOR: Fix compilation with C++98

The default assignment constructor just copies data over and we could
end up with _matte pointing twice to the same surface. It's now properly
reseted.
This commit is contained in:
Le Philousophe 2021-10-19 08:17:18 +02:00 committed by Eugene Sandulenko
parent c464d06cfd
commit 353d2f0220
2 changed files with 15 additions and 2 deletions

View File

@ -71,7 +71,13 @@ Sprite::Sprite(Frame *frame) {
_stretch = 0;
}
Sprite::Sprite(const Sprite &sprite) {
Sprite& Sprite::operator=(const Sprite &sprite) {
if (this == &sprite) {
return *this;
}
this->~Sprite();
_frame = sprite._frame;
_score = sprite._score;
_movie = sprite._movie;
@ -108,6 +114,13 @@ Sprite::Sprite(const Sprite &sprite) {
_volume = sprite._volume;
_stretch = sprite._stretch;
return *this;
}
Sprite::Sprite(const Sprite &sprite) {
_matte = nullptr;
*this = sprite;
}
Sprite::~Sprite() {

View File

@ -61,7 +61,7 @@ class Sprite {
public:
Sprite(Frame *frame = nullptr);
Sprite(const Sprite &sprite);
Sprite& operator=(const Sprite &sprite) = default;
Sprite& operator=(const Sprite &sprite);
~Sprite();
Frame *getFrame() const { return _frame; }