[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [okular/Applications/17.12] generators/poppler: Fix crash on save when we had edited forms
From:       Albert Astals Cid <null () kde ! org>
Date:       2018-01-31 22:26:58
Message-ID: E1eh0qI-0000wC-Ia () code ! kde ! org
[Download RAW message or body]

Git commit f656f1b23f7036831c04f9af6cb9eeceb5d3222c by Albert Astals Cid.
Committed on 31/01/2018 at 22:24.
Pushed by aacid into branch 'Applications/17.12'.

Fix crash on save when we had edited forms

We need to store the id locally since we need it to map
"old form" to "new form" after save and at that stage the "old form"
poppler side is gone so we're accessing invalid memory

M  +6    -3    generators/poppler/formfields.cpp
M  +3    -0    generators/poppler/formfields.h

https://commits.kde.org/okular/f656f1b23f7036831c04f9af6cb9eeceb5d3222c

diff --git a/generators/poppler/formfields.cpp b/generators/poppler/formfields.cpp
index 3c177f078..5539525e7 100644
--- a/generators/poppler/formfields.cpp
+++ b/generators/poppler/formfields.cpp
@@ -33,6 +33,7 @@ PopplerFormFieldButton::PopplerFormFieldButton( Poppler::FormFieldButton * field
     : Okular::FormFieldButton(), m_field( field )
 {
     m_rect = Okular::NormalizedRect::fromQRectF( m_field->rect() );
+    m_id = m_field->id();
     SET_ACTIONS
 }
 
@@ -48,7 +49,7 @@ Okular::NormalizedRect PopplerFormFieldButton::rect() const
 
 int PopplerFormFieldButton::id() const
 {
-    return m_field->id();
+    return m_id;
 }
 
 QString PopplerFormFieldButton::name() const
@@ -110,6 +111,7 @@ PopplerFormFieldText::PopplerFormFieldText( Poppler::FormFieldText * field )
     : Okular::FormFieldText(), m_field( field )
 {
     m_rect = Okular::NormalizedRect::fromQRectF( m_field->rect() );
+    m_id = m_field->id();
     SET_ACTIONS
 }
 
@@ -125,7 +127,7 @@ Okular::NormalizedRect PopplerFormFieldText::rect() const
 
 int PopplerFormFieldText::id() const
 {
-    return m_field->id();
+    return m_id;
 }
 
 QString PopplerFormFieldText::name() const
@@ -202,6 +204,7 @@ PopplerFormFieldChoice::PopplerFormFieldChoice( Poppler::FormFieldChoice * field
     : Okular::FormFieldChoice(), m_field( field )
 {
     m_rect = Okular::NormalizedRect::fromQRectF( m_field->rect() );
+    m_id = m_field->id();
     SET_ACTIONS
 }
 
@@ -217,7 +220,7 @@ Okular::NormalizedRect PopplerFormFieldChoice::rect() const
 
 int PopplerFormFieldChoice::id() const
 {
-    return m_field->id();
+    return m_id;
 }
 
 QString PopplerFormFieldChoice::name() const
diff --git a/generators/poppler/formfields.h b/generators/poppler/formfields.h
index 842236428..c5dfcf5fc 100644
--- a/generators/poppler/formfields.h
+++ b/generators/poppler/formfields.h
@@ -37,6 +37,7 @@ class PopplerFormFieldButton : public Okular::FormFieldButton
     private:
         Poppler::FormFieldButton * m_field;
         Okular::NormalizedRect m_rect;
+        int m_id;
 
 };
 
@@ -67,6 +68,7 @@ class PopplerFormFieldText : public Okular::FormFieldText
     private:
         Poppler::FormFieldText * m_field;
         Okular::NormalizedRect m_rect;
+        int m_id;
 
 };
 
@@ -99,6 +101,7 @@ class PopplerFormFieldChoice : public Okular::FormFieldChoice
     private:
         Poppler::FormFieldChoice * m_field;
         Okular::NormalizedRect m_rect;
+        int m_id;
 
 };
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic