[poppler] qt5/src

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Dec 24 11:34:02 UTC 2019


 qt5/src/poppler-form.cc |   18 +++++++-----------
 qt5/src/poppler-form.h  |    5 +++--
 2 files changed, 10 insertions(+), 13 deletions(-)

New commits:
commit 165bfbe220cd395a829deede92f3a0d4648d5ba6
Author: Oliver Sander <oliver.sander at tu-dresden.de>
Date:   Mon Nov 25 10:14:24 2019 +0100

    Use std::unique_ptr for m_formData
    
    To make it clear that it is an owning pointer.

diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc
index a3a5fd5a..5917e0a7 100644
--- a/qt5/src/poppler-form.cc
+++ b/qt5/src/poppler-form.cc
@@ -101,8 +101,8 @@ FormFieldIcon::~FormFieldIcon()
   delete d_ptr;
 }
 
-FormField::FormField(FormFieldData &dd)
-  : m_formData(&dd)
+FormField::FormField(std::unique_ptr<FormFieldData> dd)
+  : m_formData(std::move(dd))
 {
   const int rotation = m_formData->page->getRotate();
   // reading the coords
@@ -129,11 +129,7 @@ FormField::FormField(FormFieldData &dd)
   m_formData->box = QRectF(topLeft, QSizeF(bottomRight.x() - topLeft.x(), bottomRight.y() - topLeft.y()));
 }
 
-FormField::~FormField()
-{
-  delete m_formData;
-  m_formData = nullptr;
-}
+FormField::~FormField() = default;
 
 QRectF FormField::rect() const
 {
@@ -273,7 +269,7 @@ Link *FormField::additionalAction(Annotation::AdditionalActionType type) const
 }
 
 FormFieldButton::FormFieldButton(DocumentData *doc, ::Page *p, ::FormWidgetButton *w)
-  : FormField(*new FormFieldData(doc, p, w))
+  : FormField(std::make_unique<FormFieldData>(doc, p, w))
 {
 }
 
@@ -394,7 +390,7 @@ QList<int> FormFieldButton::siblings() const
 
 
 FormFieldText::FormFieldText(DocumentData *doc, ::Page *p, ::FormWidgetText *w)
-  : FormField(*new FormFieldData(doc, p, w))
+  : FormField(std::make_unique<FormFieldData>(doc, p, w))
 {
 }
 
@@ -482,7 +478,7 @@ void FormFieldText::setFontSize(int fontSize)
 }
 
 FormFieldChoice::FormFieldChoice(DocumentData *doc, ::Page *p, ::FormWidgetChoice *w)
-  : FormField(*new FormFieldData(doc, p, w))
+  : FormField(std::make_unique<FormFieldData>(doc, p, w))
 {
 }
 
@@ -910,7 +906,7 @@ SignatureValidationInfo &SignatureValidationInfo::operator=(const SignatureValid
 }
 
 FormFieldSignature::FormFieldSignature(DocumentData *doc, ::Page *p, ::FormWidgetSignature *w)
-  : FormField(*new FormFieldData(doc, p, w))
+  : FormField(std::make_unique<FormFieldData>(doc, p, w))
 {
 }
 
diff --git a/qt5/src/poppler-form.h b/qt5/src/poppler-form.h
index 836ada37..3918fc7d 100644
--- a/qt5/src/poppler-form.h
+++ b/qt5/src/poppler-form.h
@@ -28,6 +28,7 @@
 #ifndef _POPPLER_QT5_FORM_H_
 #define _POPPLER_QT5_FORM_H_
 
+#include <memory>
 #include <ctime>
 #include <QtCore/QDateTime>
 #include <QtCore/QList>
@@ -205,9 +206,9 @@ namespace Poppler {
 
     protected:
 	/// \cond PRIVATE
-	FormField(FormFieldData &dd);
+	FormField(std::unique_ptr<FormFieldData> dd);
 
-	FormFieldData *m_formData;
+	std::unique_ptr<FormFieldData> m_formData;
 	/// \endcond
 
     private:


More information about the poppler mailing list