Commit 887d3575 authored by Oliver Sander's avatar Oliver Sander Committed by Albert Astals Cid

LinkSound: Store Sound in a std::unique_ptr

Because the LinkSound class does own the pointer.
parent 57c7c79d
......@@ -6140,7 +6140,7 @@ AnnotSound::~AnnotSound() = default;
void AnnotSound::initialize(PDFDoc *docA, Dict* dict) {
Object obj1 = dict->lookup("Sound");
sound.reset(Sound::parseSound(&obj1));
sound = Sound::parseSound(&obj1);
if (!sound) {
error(errSyntaxError, -1, "Bad Annot Sound");
ok = false;
......
......@@ -707,10 +707,6 @@ LinkSound::LinkSound(const Object *soundObj) {
}
}
LinkSound::~LinkSound() {
delete sound;
}
//------------------------------------------------------------------------
// LinkRendition
//------------------------------------------------------------------------
......
......@@ -387,8 +387,6 @@ public:
LinkSound(const Object *soundObj);
~LinkSound() override;
bool isOk() const override { return sound != nullptr; }
LinkActionKind getKind() const override { return actionSound; }
......@@ -397,7 +395,7 @@ public:
bool getSynchronous() const { return sync; }
bool getRepeat() const { return repeat; }
bool getMix() const { return mix; }
Sound *getSound() const { return sound; }
Sound *getSound() const { return sound.get(); }
private:
......@@ -405,7 +403,7 @@ private:
bool sync;
bool repeat;
bool mix;
Sound *sound;
std::unique_ptr<Sound> sound;
};
//------------------------------------------------------------------------
......
......@@ -22,7 +22,7 @@
#include "Stream.h"
#include "FileSpec.h"
Sound *Sound::parseSound(Object *obj)
std::unique_ptr<Sound> Sound::parseSound(Object *obj)
{
// let's try to see if this Object is a Sound, according to the PDF specs
// (section 9.2)
......@@ -40,7 +40,7 @@ Sound *Sound::parseSound(Object *obj)
// the Dict must have the 'R' key of type num
Object tmp = dict->lookup("R");
if (tmp.isNum()) {
return new Sound(obj);
return std::unique_ptr<Sound>(new Sound(obj));
} else {
return nullptr;
}
......
......@@ -20,6 +20,8 @@
#ifndef Sound_H
#define Sound_H
#include <memory>
class Object;
class Stream;
......@@ -41,7 +43,7 @@ class Sound
{
public:
// Try to parse the Object obj
static Sound *parseSound(Object *obj);
static std::unique_ptr<Sound> parseSound(Object *obj);
// Destructor
~Sound();
......
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