summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Sander <oliver.sander@tu-dresden.de>2021-07-08 20:56:49 +0200
committerOliver Sander <oliver.sander@tu-dresden.de>2021-07-08 20:56:49 +0200
commitab409a6ec85dc7511dbe8ea6b2e4d7897f36670b (patch)
treef0c9155f6cba855a08a24576fb6dfeb1649edbce
parent1d23101ccebe14261c6afc024ea14f29d209e760 (diff)
Document that a document has to outlive its pages
Because the Page objects handed out by Document objects store a pointer to the document. If the Document object is deleted before a Page object it handed out, that Page object will have a stale pointer.
-rw-r--r--qt5/src/poppler-qt5.h5
-rw-r--r--qt6/src/poppler-qt6.h5
2 files changed, 10 insertions, 0 deletions
diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h
index a55fb9a4..75f51e7c 100644
--- a/qt5/src/poppler-qt5.h
+++ b/qt5/src/poppler-qt5.h
@@ -1339,6 +1339,11 @@ public:
This function can return nullptr if for some reason the page can't be properly parsed.
\param index the page number index
+
+ \warning The Page object returned by this method internally stores a pointer
+ to the document that it was created from. This pointer will go stale if you
+ delete the Document object. Therefore the Document object needs to be kept alive
+ as long as you want to use the Page object.
*/
Page *page(int index) const;
diff --git a/qt6/src/poppler-qt6.h b/qt6/src/poppler-qt6.h
index bad34bc5..2ab7097d 100644
--- a/qt6/src/poppler-qt6.h
+++ b/qt6/src/poppler-qt6.h
@@ -1216,6 +1216,11 @@ public:
This function can return empty unique pointer if for some reason the page can't be properly parsed.
\param index the page number index
+
+ \warning The Page object returned by this method internally stores a pointer
+ to the document that it was created from. This pointer will go stale if you
+ delete the Document object. Therefore the Document object needs to be kept alive
+ as long as you want to use the Page object.
*/
std::unique_ptr<Page> page(int index) const;