summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Sander <oliver.sander@tu-dresden.de>2020-01-25 17:29:54 +0100
committerAlbert Astals Cid <tsdgeos@yahoo.es>2020-02-23 16:46:59 +0000
commit887d35751979d3441a18db00b99cfc5b6b8d958f (patch)
tree7cb92ddf9bf1bf0def14912ffb47fd295af7605e
parent57c7c79df6105300f32b1f5d8775a2be8d1b96f9 (diff)
LinkSound: Store Sound in a std::unique_ptr
Because the LinkSound class does own the pointer.
-rw-r--r--poppler/Annot.cc2
-rw-r--r--poppler/Link.cc4
-rw-r--r--poppler/Link.h6
-rw-r--r--poppler/Sound.cc4
-rw-r--r--poppler/Sound.h4
5 files changed, 8 insertions, 12 deletions
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 98f9dfef..102dbf3f 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -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;
diff --git a/poppler/Link.cc b/poppler/Link.cc
index af8d44dd..9433fd9f 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -707,10 +707,6 @@ LinkSound::LinkSound(const Object *soundObj) {
}
}
-LinkSound::~LinkSound() {
- delete sound;
-}
-
//------------------------------------------------------------------------
// LinkRendition
//------------------------------------------------------------------------
diff --git a/poppler/Link.h b/poppler/Link.h
index 184e43e7..053cbb85 100644
--- a/poppler/Link.h
+++ b/poppler/Link.h
@@ -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;
};
//------------------------------------------------------------------------
diff --git a/poppler/Sound.cc b/poppler/Sound.cc
index 3e0323a7..20c1b7f8 100644
--- a/poppler/Sound.cc
+++ b/poppler/Sound.cc
@@ -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;
}
diff --git a/poppler/Sound.h b/poppler/Sound.h
index 802f6ff4..5c049448 100644
--- a/poppler/Sound.h
+++ b/poppler/Sound.h
@@ -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();