Rework AnnotPopup parent handling code

The old code was not updating the parent member on setParent
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index dc39507..fd2ea0f 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1927,9 +1927,11 @@
 }
 
 void AnnotPopup::initialize(PDFDoc *docA, Dict *dict) {
-  parent = dict->lookupNF("Parent").copy();
-  if (!parent.isRef()) {
-    parent.setToNull();
+  const Object &parentObj = dict->lookupNF("Parent");
+  if (parentObj.isRef()) {
+    parentRef = parentObj.getRef();
+  } else {
+    parentRef = Ref::INVALID();
   }
 
   Object obj1 = dict->lookup("Open");
@@ -1941,7 +1943,7 @@
 }
 
 void AnnotPopup::setParent(Annot *parentA) {
-  const Ref parentRef = parentA->getRef();
+  parentRef = parentA->getRef();
   update ("Parent", Object(parentRef));
 }
 
diff --git a/poppler/Annot.h b/poppler/Annot.h
index 0200bb6..7bcb6b2 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -788,7 +788,7 @@
   AnnotPopup(PDFDoc *docA, Object &&dictObject, const Object *obj);
   ~AnnotPopup();
 
-  Object *getParentNF() { return &parent; }
+  bool hasParent() const { return parentRef != Ref::INVALID(); }
   void setParent(Annot *parentA);
   bool getOpen() const { return open; }
   void setOpen(bool openA);
@@ -796,7 +796,7 @@
 protected:
   void initialize(PDFDoc *docA, Dict *dict);
 
-  Object parent; // Parent
+  Ref parentRef; // Parent
   bool open;   // Open
 };
 
diff --git a/poppler/Object.h b/poppler/Object.h
index 77a40cd..914b10b 100644
--- a/poppler/Object.h
+++ b/poppler/Object.h
@@ -82,12 +82,18 @@
 struct Ref {
   int num;			// object number
   int gen;			// generation number
+
+  static constexpr Ref INVALID() { return {-1, -1}; };
 };
 
 inline bool operator== (const Ref lhs, const Ref rhs) noexcept {
   return lhs.num == rhs.num && lhs.gen == rhs.gen;
 }
 
+inline bool operator!= (const Ref lhs, const Ref rhs) noexcept {
+  return lhs.num != rhs.num || lhs.gen != rhs.gen;
+}
+
 inline bool operator< (const Ref lhs, const Ref rhs) noexcept {
   if (lhs.num != rhs.num)
     return lhs.num < rhs.num;
diff --git a/poppler/Page.cc b/poppler/Page.cc
index 2cb7514..447a94d 100644
--- a/poppler/Page.cc
+++ b/poppler/Page.cc
@@ -401,7 +401,7 @@
   // so add to the list only Popup annots without a
   // markup annotation associated.
   if (annot->getType() != Annot::typePopup ||
-      static_cast<AnnotPopup*>(annot)->getParentNF()->isNull()) {
+      !static_cast<AnnotPopup*>(annot)->hasParent()) {
     annots->appendAnnot(annot);
   }
   annot->setPage(num, true);