summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Sander <oliver.sander@tu-dresden.de>2019-11-22 08:50:35 +0100
committerAlbert Astals Cid <tsdgeos@yahoo.es>2020-02-26 21:35:54 +0000
commita11fc679a701879ffd8ba6ccbd4b0a08a03440e6 (patch)
tree62aa7bf078efea751c0806b526a7ac9f1117a8d0
parentafa0528e1dfaafeb09ad9fb52902b13b378e0250 (diff)
Use a vector of unique_ptr for LinkAction::nextActionList
This makes it clear that the vector owns the LinkAction objects.
-rw-r--r--poppler/Link.cc14
-rw-r--r--poppler/Link.h5
-rw-r--r--qt5/src/poppler-page.cc4
3 files changed, 9 insertions, 14 deletions
diff --git a/poppler/Link.cc b/poppler/Link.cc
index 318c6b96..19581e84 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -51,11 +51,7 @@
//------------------------------------------------------------------------
LinkAction::LinkAction() = default;
-LinkAction::~LinkAction() {
- for (auto entry : nextActionList) {
- delete entry;
- }
-}
+LinkAction::~LinkAction() = default;
LinkAction *LinkAction::parseDest(const Object *obj) {
LinkAction *action;
@@ -158,7 +154,7 @@ LinkAction *LinkAction::parseAction(const Object *obj, const GooString *baseURI,
// parse the next actions
const Object nextObj = obj->dictLookup("Next");
- std::vector<LinkAction*> actionList;
+ std::vector<std::unique_ptr<LinkAction> > actionList;
if (nextObj.isDict()) {
// Prevent circles in the tree by checking the ref against used refs in
@@ -173,7 +169,7 @@ LinkAction *LinkAction::parseAction(const Object *obj, const GooString *baseURI,
}
actionList.reserve(1);
- actionList.push_back(parseAction(&nextObj, nullptr, seenNextActions));
+ actionList.push_back(std::unique_ptr<LinkAction>(parseAction(&nextObj, nullptr, seenNextActions)));
} else if (nextObj.isArray()) {
const Array *a = nextObj.getArray();
const int n = a->getLength();
@@ -195,7 +191,7 @@ LinkAction *LinkAction::parseAction(const Object *obj, const GooString *baseURI,
}
}
- actionList.push_back(parseAction(&obj3, nullptr, seenNextActions));
+ actionList.push_back(std::unique_ptr<LinkAction>(parseAction(&obj3, nullptr, seenNextActions)));
}
}
@@ -204,7 +200,7 @@ LinkAction *LinkAction::parseAction(const Object *obj, const GooString *baseURI,
return action;
}
-const std::vector<LinkAction*>& LinkAction::nextActions() const {
+const std::vector<std::unique_ptr<LinkAction> >& LinkAction::nextActions() const {
return nextActionList;
}
diff --git a/poppler/Link.h b/poppler/Link.h
index 1871890f..61731e72 100644
--- a/poppler/Link.h
+++ b/poppler/Link.h
@@ -85,13 +85,12 @@ public:
static LinkAction *parseAction(const Object *obj, const GooString *baseURI = nullptr);
// A List of the next actions to execute in order.
- // The list contains pointer to LinkAction objects.
- const std::vector<LinkAction*>& nextActions() const;
+ const std::vector<std::unique_ptr<LinkAction> >& nextActions() const;
private:
static LinkAction *parseAction(const Object *obj, const GooString *baseURI, std::set<int> *seenNextActions);
- std::vector<LinkAction*> nextActionList;
+ std::vector<std::unique_ptr<LinkAction> > nextActionList;
};
//------------------------------------------------------------------------
diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc
index e36f6fd3..a0862189 100644
--- a/qt5/src/poppler-page.cc
+++ b/qt5/src/poppler-page.cc
@@ -361,9 +361,9 @@ Link* PageData::convertLinkActionToLink(::LinkAction * a, DocumentData *parentDo
if ( popplerLink )
{
QVector<Link *> links;
- for ( ::LinkAction *nextAction : a->nextActions() )
+ for ( const std::unique_ptr<::LinkAction>& nextAction : a->nextActions() )
{
- links << convertLinkActionToLink( nextAction, parentDoc, linkArea );
+ links << convertLinkActionToLink( nextAction.get(), parentDoc, linkArea );
}
LinkPrivate::get(popplerLink)->nextLinks = links;
}