summaryrefslogtreecommitdiff
path: root/fpdfsdk/include
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-08-01 10:10:36 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-01 10:10:36 -0700
commitca97a8ee99cad1ddb6a69e14cc7a501b3e8092a4 (patch)
treeedae775ef47a5eb65244158c9142974592db4c15 /fpdfsdk/include
parentab47acec5252d4a09da3cbde1a118b5255fe52ae (diff)
downloadpdfium-ca97a8ee99cad1ddb6a69e14cc7a501b3e8092a4.tar.xz
Watch for destruction of CPDFSDK_widget during callback
Speculative fix since I had trouble with the repro. BUG=632709 Review-Url: https://codereview.chromium.org/2197793002
Diffstat (limited to 'fpdfsdk/include')
-rw-r--r--fpdfsdk/include/fsdk_baseform.h34
1 files changed, 24 insertions, 10 deletions
diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h
index 91603aa41f..d386c7fa2d 100644
--- a/fpdfsdk/include/fsdk_baseform.h
+++ b/fpdfsdk/include/fsdk_baseform.h
@@ -8,6 +8,7 @@
#define FPDFSDK_INCLUDE_FSDK_BASEFORM_H_
#include <map>
+#include <set>
#include <vector>
#include "core/fpdfdoc/include/ipdf_formnotify.h"
@@ -62,6 +63,17 @@ struct PDFSDK_FieldAction {
class CPDFSDK_Widget : public CPDFSDK_BAAnnot {
public:
+ class Observer {
+ public:
+ explicit Observer(CPDFSDK_Widget** pWatchedPtr);
+ ~Observer();
+
+ void OnWidgetDestroyed();
+
+ private:
+ CPDFSDK_Widget** m_pWatchedPtr;
+ };
+
#ifdef PDF_ENABLE_XFA
CXFA_FFWidget* GetMixXFAWidget() const;
CXFA_FFWidget* GetGroupMixXFAWidget();
@@ -91,6 +103,9 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot {
CPDFSDK_InterForm* pInterForm);
~CPDFSDK_Widget() override;
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
// CPDFSDK_Annot
CFX_ByteString GetSubType() const override;
CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT) override;
@@ -172,6 +187,14 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot {
int32_t GetAppearanceAge() const;
int32_t GetValueAge() const;
+ FX_BOOL IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode);
+ void DrawAppearance(CFX_RenderDevice* pDevice,
+ const CFX_Matrix* pUser2Device,
+ CPDF_Annot::AppearanceMode mode,
+ const CPDF_RenderOptions* pOptions) override;
+
+ FX_BOOL HitTest(FX_FLOAT pageX, FX_FLOAT pageY);
+
private:
void ResetAppearance_PushButton();
void ResetAppearance_CheckBox();
@@ -194,20 +217,11 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot {
void AddImageToAppearance(const CFX_ByteString& sAPType, CPDF_Stream* pImage);
void RemoveAppearance(const CFX_ByteString& sAPType);
- public:
- FX_BOOL IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode);
- void DrawAppearance(CFX_RenderDevice* pDevice,
- const CFX_Matrix* pUser2Device,
- CPDF_Annot::AppearanceMode mode,
- const CPDF_RenderOptions* pOptions) override;
-
- FX_BOOL HitTest(FX_FLOAT pageX, FX_FLOAT pageY);
-
- private:
CPDFSDK_InterForm* const m_pInterForm;
FX_BOOL m_bAppModified;
int32_t m_nAppAge;
int32_t m_nValueAge;
+ std::set<Observer*> m_Observers;
#ifdef PDF_ENABLE_XFA
mutable CXFA_FFWidget* m_hMixXFAWidget;