[evince/wip/chpe/fix-dispose] pdf: Fix dispose implementation




commit 156eb4437268f2c525f017a445552175cfddea20
Author: Christian Persch <chpe src gnome org>
Date:   Tue Dec 7 18:53:11 2021 +0100

    pdf: Fix dispose implementation
    
    Dispose must be safe against multiple runs, so set pointers to NULL
    after freeing them.

 backend/pdf/ev-poppler.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
---
diff --git a/backend/pdf/ev-poppler.c b/backend/pdf/ev-poppler.c
index 8dc9035e1..27c9a2e8e 100644
--- a/backend/pdf/ev-poppler.c
+++ b/backend/pdf/ev-poppler.c
@@ -224,17 +224,9 @@ pdf_document_dispose (GObject *object)
                pdf_document->annots = NULL;
        }
 
-       if (pdf_document->document) {
-               g_object_unref (pdf_document->document);
-       }
-
-       if (pdf_document->font_info) {
-               poppler_font_info_free (pdf_document->font_info);
-       }
-
-       if (pdf_document->fonts_iter) {
-               poppler_fonts_iter_free (pdf_document->fonts_iter);
-       }
+        g_clear_object (&pdf_document->document);
+        g_clear_pointer (&pdf_document->font_info, poppler_font_info_free);
+        g_clear_pointer (&pdf_document->fonts_iter, poppler_fonts_iter_free);
 
        G_OBJECT_CLASS (pdf_document_parent_class)->dispose (object);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]