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

Use a vector of unique_ptr for LinkAction::nextActionList

This makes it clear that the vector owns the LinkAction objects.
parent afa0528e
......@@ -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;
}
......
......@@ -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;
};
//------------------------------------------------------------------------
......
......@@ -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;
}
......
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