[poppler] 2 commits - qt5/src qt5/tests
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Oct 31 17:27:44 UTC 2018
qt5/src/poppler-annotation.cc | 2 +-
qt5/tests/check_annotations.cpp | 33 +++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
New commits:
commit 2be4ba842e023ea8662755b11b905c22e733e4c8
Author: Albert Astals Cid <aacid at kde.org>
Date: Wed Oct 31 17:52:51 2018 +0100
qt5: Test two leaks in a test
diff --git a/qt5/tests/check_annotations.cpp b/qt5/tests/check_annotations.cpp
index b4b505dd..d591bd70 100644
--- a/qt5/tests/check_annotations.cpp
+++ b/qt5/tests/check_annotations.cpp
@@ -26,6 +26,7 @@ void TestAnnotations::checkQColorPrecision() {
double normalized = static_cast<uint16_t>(i) / static_cast<double>(std::numeric_limits<uint16_t>::max());
GooString* serialized = GooString::format("{0:.5f}", normalized);
double deserialized = gatof( serialized->getCString() );
+ delete serialized;
uint16_t denormalized = std::round(deserialized * std::numeric_limits<uint16_t>::max());
if (static_cast<uint16_t>(i) != denormalized) {
precisionOk = false;
@@ -98,6 +99,7 @@ void TestAnnotations::checkFontSizeAndColor()
if (annot != annots.constEnd())
++annot;
}
+ qDeleteAll(annots);
}
}
commit aeb2c1798ef39b5d3a167f4531e9f09dcb18e88d
Author: Albert Astals Cid <aacid at kde.org>
Date: Wed Oct 31 17:38:26 2018 +0100
qt5: Fix crash when adding Highlight Annotations
diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc
index a30088d6..64190bce 100644
--- a/qt5/src/poppler-annotation.cc
+++ b/qt5/src/poppler-annotation.cc
@@ -3139,7 +3139,7 @@ QList< HighlightAnnotation::Quad > HighlightAnnotationPrivate::fromQuadrilateral
AnnotQuadrilaterals * HighlightAnnotationPrivate::toQuadrilaterals(const QList< HighlightAnnotation::Quad > &quads) const
{
const int count = quads.size();
- std::unique_ptr<AnnotQuadrilaterals::AnnotQuadrilateral[]> ac;
+ auto ac = std::make_unique<AnnotQuadrilaterals::AnnotQuadrilateral[]>(count);
double MTX[6];
fillTransformationMTX(MTX);
diff --git a/qt5/tests/check_annotations.cpp b/qt5/tests/check_annotations.cpp
index 36aa1bd3..b4b505dd 100644
--- a/qt5/tests/check_annotations.cpp
+++ b/qt5/tests/check_annotations.cpp
@@ -16,6 +16,7 @@ class TestAnnotations : public QObject
private slots:
void checkQColorPrecision();
void checkFontSizeAndColor();
+ void checkHighlightFromAndToQuads();
};
/* Is .5f sufficient for 16 bit color channel roundtrip trough save and load on all architectures? */
@@ -100,6 +101,36 @@ void TestAnnotations::checkFontSizeAndColor()
}
}
+namespace Poppler {
+ static bool operator==(const Poppler::HighlightAnnotation::Quad &a, const Poppler::HighlightAnnotation::Quad &b)
+ {
+ // FIXME We do not compare capStart, capEnd and feather since AnnotQuadrilaterals doesn't contain that info and thus
+ // HighlightAnnotationPrivate::fromQuadrilaterals uses default values
+ return a.points[0] == b.points[0] && a.points[1] == b.points[1] && a.points[2] == b.points[2] && a.points[3] == b.points[3];
+ }
+}
+
+void TestAnnotations::checkHighlightFromAndToQuads()
+{
+ std::unique_ptr<Poppler::Document> doc{
+ Poppler::Document::load(TESTDATADIR "/unittestcases/UseNone.pdf")
+ };
+
+ std::unique_ptr<Poppler::Page> page{
+ doc->page(0)
+ };
+
+ auto ha = std::make_unique<Poppler::HighlightAnnotation>();
+ page->addAnnotation(ha.get());
+
+ const QList<Poppler::HighlightAnnotation::Quad> quads = {
+ { {{0, 0.1}, {0.2, 0.3}, {0.4, 0.5}, {0.6, 0.7}}, false, false, 0 },
+ { {{0.8, 0.9}, {0.1, 0.2}, {0.3, 0.4}, {0.5, 0.6}}, true, false, 0.4 }
+ };
+ ha->setHighlightQuads(quads);
+ QCOMPARE(ha->highlightQuads(), quads);
+}
+
QTEST_GUILESS_MAIN(TestAnnotations)
#include "check_annotations.moc"
More information about the poppler
mailing list