From 07889cdfd8a261dc5ae6eb72c26a8a3ec2e35930 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Tue, 15 Feb 2022 17:14:44 +0100 Subject: Make PDFDoc constructor take the filename as unique_ptr Makes it clear that it will own the given GooString --- glib/poppler-document.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'glib') diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc index 29172833..00991937 100644 --- a/glib/poppler-document.cc +++ b/glib/poppler-document.cc @@ -222,16 +222,13 @@ PopplerDocument *poppler_document_new_from_file(const char *uri, const char *pas } delete[] filenameW; #else - GooString *filename_g; - filename_g = new GooString(filename); - newDoc = new PDFDoc(filename_g, password_g, password_g); + newDoc = new PDFDoc(std::make_unique(filename), password_g, password_g); if (!newDoc->isOk() && newDoc->getErrorCode() == errEncrypted && password) { /* Try again with original password (which comes from GTK in UTF8) Issue #824 */ - filename_g = filename_g->copy(); delete newDoc; delete password_g; password_g = new GooString(password); - newDoc = new PDFDoc(filename_g, password_g, password_g); + newDoc = new PDFDoc(std::make_unique(filename), password_g, password_g); } #endif g_free(filename); -- cgit v1.2.3