[poppler] qt5/src
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Jan 4 10:24:32 UTC 2020
qt5/src/poppler-link-private.h | 14 +++++++++++---
qt5/src/poppler-link.h | 4 ++--
qt5/src/poppler-optcontent.cc | 10 +++++-----
qt5/src/poppler-page.cc | 2 +-
4 files changed, 19 insertions(+), 11 deletions(-)
New commits:
commit 0053b82841d37077b9b22ea393bb807fbe53eb64
Author: Oliver Sander <oliver.sander at tu-dresden.de>
Date: Fri Jan 3 17:54:17 2020 +0100
Deep-copy the LinkOCGAction object
The convertLinkActionToLink method deep-copies every poppler LinkAction
object into a Link object as used by the Qt5 frontend. With one
exception: LinkOCGState objects are not deep-copied, but pointers to
them are stored instead. This makes for a memory management that is
inconsistent, difficult to understand, and prone to memory errors.
The present patch introduces deep-copying for LinkOCGState objects
as well.
diff --git a/qt5/src/poppler-link-private.h b/qt5/src/poppler-link-private.h
index 766f1899..ed12f70b 100644
--- a/qt5/src/poppler-link-private.h
+++ b/qt5/src/poppler-link-private.h
@@ -20,6 +20,10 @@
#ifndef _POPPLER_LINK_PRIVATE_H_
#define _POPPLER_LINK_PRIVATE_H_
+#include <vector>
+
+#include "Link.h"
+
class LinkOCGState;
namespace Poppler {
@@ -56,13 +60,17 @@ public:
class LinkOCGStatePrivate : public LinkPrivate
{
public:
- LinkOCGStatePrivate( const QRectF &area, ::LinkOCGState *plocg )
+ LinkOCGStatePrivate( const QRectF &area,
+ const std::vector<::LinkOCGState::StateList>& sList,
+ bool pRB )
: LinkPrivate( area )
- , popplerLinkOCGState( plocg )
+ , stateList( sList )
+ , preserveRB( pRB )
{
}
- ::LinkOCGState *popplerLinkOCGState;
+ std::vector<::LinkOCGState::StateList> stateList;
+ bool preserveRB;
};
diff --git a/qt5/src/poppler-link.h b/qt5/src/poppler-link.h
index 93221846..24dd24c4 100644
--- a/qt5/src/poppler-link.h
+++ b/qt5/src/poppler-link.h
@@ -177,8 +177,6 @@ class POPPLER_QT5_EXPORT LinkDestination
*/
class POPPLER_QT5_EXPORT Link
{
- friend class OptContentModel;
-
public:
/// \cond PRIVATE
Link( const QRectF &linkArea );
@@ -624,6 +622,8 @@ class POPPLER_QT5_EXPORT LinkMovie : public Link
*/
class POPPLER_QT5_EXPORT LinkOCGState : public Link
{
+ friend class OptContentModel;
+
public:
/**
* Create a new OCGState link. This is only used by Poppler::Page.
diff --git a/qt5/src/poppler-optcontent.cc b/qt5/src/poppler-optcontent.cc
index ad959db8..5b71be80 100644
--- a/qt5/src/poppler-optcontent.cc
+++ b/qt5/src/poppler-optcontent.cc
@@ -397,23 +397,23 @@ namespace Poppler
void OptContentModel::applyLink( LinkOCGState *link )
{
- ::LinkOCGState *popplerLinkOCGState = static_cast<LinkOCGStatePrivate*>(link->d_ptr)->popplerLinkOCGState;
+ LinkOCGStatePrivate *linkPrivate = link->d_func();
QSet<OptContentItem *> changedItems;
- const std::vector<::LinkOCGState::StateList>& statesList = popplerLinkOCGState->getStateList();
+ const std::vector<::LinkOCGState::StateList>& statesList = linkPrivate->stateList;
for (const ::LinkOCGState::StateList& stateList : statesList) {
const std::vector<Ref>& refsList = stateList.list;
for (const Ref& ref : refsList) {
OptContentItem *item = d->itemFromRef(QString::number(ref.num));
if (stateList.st == ::LinkOCGState::On) {
- item->setState(OptContentItem::On, popplerLinkOCGState->getPreserveRB(), changedItems);
+ item->setState(OptContentItem::On, linkPrivate->preserveRB, changedItems);
} else if (stateList.st == ::LinkOCGState::Off) {
- item->setState(OptContentItem::Off, popplerLinkOCGState->getPreserveRB(), changedItems);
+ item->setState(OptContentItem::Off, linkPrivate->preserveRB, changedItems);
} else {
OptContentItem::ItemState newState = item->state() == OptContentItem::On ? OptContentItem::Off : OptContentItem::On;
- item->setState(newState, popplerLinkOCGState->getPreserveRB(), changedItems);
+ item->setState(newState, linkPrivate->preserveRB, changedItems);
}
}
}
diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc
index 29394d20..f40b00e6 100644
--- a/qt5/src/poppler-page.cc
+++ b/qt5/src/poppler-page.cc
@@ -340,7 +340,7 @@ Link* PageData::convertLinkActionToLink(::LinkAction * a, DocumentData *parentDo
{
::LinkOCGState *plocg = (::LinkOCGState *)a;
- LinkOCGStatePrivate *locgp = new LinkOCGStatePrivate( linkArea, plocg );
+ LinkOCGStatePrivate *locgp = new LinkOCGStatePrivate( linkArea, plocg->getStateList(), plocg->getPreserveRB() );
popplerLink = new LinkOCGState( locgp );
}
break;
More information about the poppler
mailing list