summaryrefslogtreecommitdiff
path: root/xfa/fxfa/cxfa_widgetacc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/cxfa_widgetacc.cpp')
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp58
1 files changed, 38 insertions, 20 deletions
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index 6e76119115..4c8e37291a 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -67,9 +67,15 @@ class CXFA_TextLayoutData : public CXFA_WidgetLayoutData {
class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData {
public:
CXFA_ImageLayoutData()
- : m_bNamedImage(false), m_iImageXDpi(0), m_iImageYDpi(0) {}
+ : m_pDIBitmap(nullptr),
+ m_bNamedImage(false),
+ m_iImageXDpi(0),
+ m_iImageYDpi(0) {}
- ~CXFA_ImageLayoutData() override {}
+ ~CXFA_ImageLayoutData() override {
+ if (m_pDIBitmap && !m_bNamedImage)
+ delete m_pDIBitmap;
+ }
bool LoadImageData(CXFA_WidgetAcc* pAcc) {
if (m_pDIBitmap)
@@ -89,7 +95,7 @@ class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData {
return !!m_pDIBitmap;
}
- CFX_RetainPtr<CFX_DIBitmap> m_pDIBitmap;
+ CFX_DIBitmap* m_pDIBitmap;
bool m_bNamedImage;
int32_t m_iImageXDpi;
int32_t m_iImageYDpi;
@@ -126,9 +132,15 @@ class CXFA_TextEditData : public CXFA_FieldLayoutData {
class CXFA_ImageEditData : public CXFA_FieldLayoutData {
public:
CXFA_ImageEditData()
- : m_bNamedImage(false), m_iImageXDpi(0), m_iImageYDpi(0) {}
+ : m_pDIBitmap(nullptr),
+ m_bNamedImage(false),
+ m_iImageXDpi(0),
+ m_iImageYDpi(0) {}
- ~CXFA_ImageEditData() override {}
+ ~CXFA_ImageEditData() override {
+ if (m_pDIBitmap && !m_bNamedImage)
+ delete m_pDIBitmap;
+ }
bool LoadImageData(CXFA_WidgetAcc* pAcc) {
if (m_pDIBitmap)
@@ -145,7 +157,7 @@ class CXFA_ImageEditData : public CXFA_FieldLayoutData {
return !!m_pDIBitmap;
}
- CFX_RetainPtr<CFX_DIBitmap> m_pDIBitmap;
+ CFX_DIBitmap* m_pDIBitmap;
bool m_bNamedImage;
int32_t m_iImageXDpi;
int32_t m_iImageYDpi;
@@ -917,8 +929,7 @@ bool CXFA_WidgetAcc::CalculateImageAutoSize(CFX_SizeF& size) {
LoadImageImage();
size.clear();
- CFX_RetainPtr<CFX_DIBitmap> pBitmap = GetImageImage();
- if (pBitmap) {
+ if (CFX_DIBitmap* pBitmap = GetImageImage()) {
int32_t iImageXDpi = 0;
int32_t iImageYDpi = 0;
GetImageDpi(iImageXDpi, iImageYDpi);
@@ -947,8 +958,7 @@ bool CXFA_WidgetAcc::CalculateImageEditAutoSize(CFX_SizeF& size) {
LoadImageEditImage();
size.clear();
- CFX_RetainPtr<CFX_DIBitmap> pBitmap = GetImageEditImage();
- if (pBitmap) {
+ if (CFX_DIBitmap* pBitmap = GetImageEditImage()) {
int32_t iImageXDpi = 0;
int32_t iImageYDpi = 0;
GetImageEditDpi(iImageXDpi, iImageYDpi);
@@ -1457,34 +1467,42 @@ CXFA_TextLayout* CXFA_WidgetAcc::GetTextLayout() {
: nullptr;
}
-CFX_RetainPtr<CFX_DIBitmap> CXFA_WidgetAcc::GetImageImage() {
+CFX_DIBitmap* CXFA_WidgetAcc::GetImageImage() {
return m_pLayoutData
? static_cast<CXFA_ImageLayoutData*>(m_pLayoutData.get())
->m_pDIBitmap
: nullptr;
}
-CFX_RetainPtr<CFX_DIBitmap> CXFA_WidgetAcc::GetImageEditImage() {
+CFX_DIBitmap* CXFA_WidgetAcc::GetImageEditImage() {
return m_pLayoutData
? static_cast<CXFA_ImageEditData*>(m_pLayoutData.get())
->m_pDIBitmap
: nullptr;
}
-void CXFA_WidgetAcc::SetImageImage(
- const CFX_RetainPtr<CFX_DIBitmap>& newImage) {
+void CXFA_WidgetAcc::SetImageImage(CFX_DIBitmap* newImage) {
CXFA_ImageLayoutData* pData =
static_cast<CXFA_ImageLayoutData*>(m_pLayoutData.get());
- if (pData->m_pDIBitmap != newImage)
- pData->m_pDIBitmap = newImage;
+ if (pData->m_pDIBitmap == newImage)
+ return;
+
+ if (pData->m_pDIBitmap && !pData->m_bNamedImage)
+ delete pData->m_pDIBitmap;
+
+ pData->m_pDIBitmap = newImage;
}
-void CXFA_WidgetAcc::SetImageEditImage(
- const CFX_RetainPtr<CFX_DIBitmap>& newImage) {
+void CXFA_WidgetAcc::SetImageEditImage(CFX_DIBitmap* newImage) {
CXFA_ImageEditData* pData =
static_cast<CXFA_ImageEditData*>(m_pLayoutData.get());
- if (pData->m_pDIBitmap != newImage)
- pData->m_pDIBitmap = newImage;
+ if (pData->m_pDIBitmap == newImage)
+ return;
+
+ if (pData->m_pDIBitmap && !pData->m_bNamedImage)
+ delete pData->m_pDIBitmap;
+
+ pData->m_pDIBitmap = newImage;
}
CXFA_WidgetLayoutData* CXFA_WidgetAcc::GetWidgetLayoutData() {