From 495bda110a6ea8e7a6fc313ec0232a9ca6e3cfdc Mon Sep 17 00:00:00 2001 From: thestig Date: Thu, 28 Apr 2016 17:29:19 -0700 Subject: Do not check pointers before deleting them. XFA edition. Review-Url: https://codereview.chromium.org/1925363002 --- xfa/fde/css/fde_cssstyleselector.cpp | 18 ++- xfa/fde/css/fde_cssstyleselector.h | 4 +- xfa/fde/fde_render.cpp | 6 +- xfa/fee/fde_txtedtengine.cpp | 38 ++--- xfa/fee/fde_txtedtpage.cpp | 56 +++----- xfa/fgas/font/fgas_stdfontmgr.cpp | 12 +- xfa/fwl/basewidget/fwl_caretimp.cpp | 7 +- xfa/fwl/basewidget/fxmath_barcodeimp.cpp | 8 +- xfa/fwl/core/fwl_formimp.cpp | 26 ++-- xfa/fwl/core/fwl_noteimp.cpp | 12 +- xfa/fwl/core/fwl_widgetmgrimp.cpp | 19 ++- xfa/fwl/theme/cfwl_checkboxtp.cpp | 12 +- xfa/fwl/theme/cfwl_formtp.cpp | 31 ++-- xfa/fwl/theme/cfwl_pushbuttontp.cpp | 9 +- xfa/fwl/theme/cfwl_scrollbartp.cpp | 10 +- xfa/fwl/theme/cfwl_widgettp.cpp | 21 ++- xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp | 59 +++----- xfa/fxbarcode/BC_TwoDimWriter.cpp | 6 +- .../common/reedsolomon/BC_ReedSolomonGF256.cpp | 14 +- xfa/fxbarcode/oned/BC_OneDimWriter.cpp | 6 +- xfa/fxbarcode/pdf417/BC_PDF417.cpp | 10 +- xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp | 18 +-- xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp | 8 +- .../pdf417/BC_PDF417ECErrorCorrection.cpp | 148 ++++++------------- xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp | 12 +- xfa/fxfa/app/xfa_ffdocview.cpp | 7 +- xfa/fxfa/app/xfa_ffpushbutton.cpp | 26 ++-- xfa/fxfa/app/xfa_ffwidget.cpp | 13 +- xfa/fxfa/app/xfa_textlayout.cpp | 18 ++- xfa/fxfa/parser/xfa_document_imp.cpp | 55 +++----- xfa/fxfa/parser/xfa_document_layout_imp.cpp | 25 ++-- xfa/fxfa/parser/xfa_locale.cpp | 11 +- xfa/fxfa/parser/xfa_parser_imp.cpp | 8 +- xfa/fxfa/parser/xfa_script_imp.cpp | 156 ++++++++++----------- xfa/fxfa/parser/xfa_script_resolveprocessor.cpp | 11 +- xfa/fxgraphics/cagg_graphics.cpp | 4 +- xfa/fxgraphics/cfx_path_generator.cpp | 12 +- xfa/fxjse/context.cpp | 32 ++--- 38 files changed, 376 insertions(+), 572 deletions(-) (limited to 'xfa') diff --git a/xfa/fde/css/fde_cssstyleselector.cpp b/xfa/fde/css/fde_cssstyleselector.cpp index 8ea85b9257..55a1477b4c 100644 --- a/xfa/fde/css/fde_cssstyleselector.cpp +++ b/xfa/fde/css/fde_cssstyleselector.cpp @@ -220,18 +220,16 @@ CFDE_CSSStyleSelector::CFDE_CSSStyleSelector() m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Low] = FDE_CSSSTYLESHEETGROUP_UserAgent; } + CFDE_CSSStyleSelector::~CFDE_CSSStyleSelector() { Reset(); - if (m_pInlineStyleStore != NULL) { + if (m_pInlineStyleStore) m_pInlineStyleStore->Release(); - } - if (m_pFixedStyleStore != NULL) { + if (m_pFixedStyleStore) m_pFixedStyleStore->Release(); - } - if (m_pAccelerator != NULL) { - delete m_pAccelerator; - } + delete m_pAccelerator; } + void CFDE_CSSStyleSelector::SetFontMgr(IFX_FontMgr* pFontMgr) { m_pFontMgr = pFontMgr; } @@ -239,14 +237,14 @@ void CFDE_CSSStyleSelector::SetDefFontSize(FX_FLOAT fFontSize) { ASSERT(fFontSize > 0); m_fDefFontSize = fFontSize; } + CFDE_CSSAccelerator* CFDE_CSSStyleSelector::InitAccelerator() { - if (m_pAccelerator == NULL) { + if (!m_pAccelerator) m_pAccelerator = new CFDE_CSSAccelerator; - ASSERT(m_pAccelerator != NULL); - } m_pAccelerator->Clear(); return m_pAccelerator; } + IFDE_CSSComputedStyle* CFDE_CSSStyleSelector::CreateComputedStyle( IFDE_CSSComputedStyle* pParentStyle) { if (m_pFixedStyleStore == NULL) { diff --git a/xfa/fde/css/fde_cssstyleselector.h b/xfa/fde/css/fde_cssstyleselector.h index faadb4e4e4..6c23a9eb1d 100644 --- a/xfa/fde/css/fde_cssstyleselector.h +++ b/xfa/fde/css/fde_cssstyleselector.h @@ -398,9 +398,7 @@ class CFDE_CSSComputedStyle : public IFDE_CSSComputedStyle, uint32_t Release() override { uint32_t dwRefCount = --m_dwRefCount; if (dwRefCount == 0) { - if (m_NonInheritedData.m_pCounterStyle) - delete m_NonInheritedData.m_pCounterStyle; - + delete m_NonInheritedData.m_pCounterStyle; FXTARGET_DeleteWith(CFDE_CSSComputedStyle, m_pAllocator, this); } return dwRefCount; diff --git a/xfa/fde/fde_render.cpp b/xfa/fde/fde_render.cpp index 81e5b1b259..7c989a0c6b 100644 --- a/xfa/fde/fde_render.cpp +++ b/xfa/fde/fde_render.cpp @@ -105,10 +105,8 @@ void CFDE_RenderContext::StopRender() { m_pIterator->Release(); m_pIterator = nullptr; } - if (m_pBrush) { - delete m_pBrush; - m_pBrush = nullptr; - } + delete m_pBrush; + m_pBrush = nullptr; FX_Free(m_pCharPos); m_pCharPos = nullptr; m_iCharPosCount = 0; diff --git a/xfa/fee/fde_txtedtengine.cpp b/xfa/fee/fde_txtedtengine.cpp index 98d7841b40..1dc03dcc85 100644 --- a/xfa/fee/fde_txtedtengine.cpp +++ b/xfa/fee/fde_txtedtengine.cpp @@ -627,22 +627,16 @@ int32_t CFDE_TxtEdtEngine::GetSelRange(int32_t nIndex, int32_t& nStart) { nStart = m_SelRangePtrArr[nIndex]->nStart; return m_SelRangePtrArr[nIndex]->nCount; } + void CFDE_TxtEdtEngine::ClearSelection() { int32_t nCount = m_SelRangePtrArr.GetSize(); - FDE_LPTXTEDTSELRANGE lpRange = NULL; - int32_t i = 0; - for (i = 0; i < nCount; i++) { - lpRange = m_SelRangePtrArr[i]; - if (lpRange != NULL) { - delete lpRange; - lpRange = NULL; - } - } + for (int i = 0; i < nCount; ++i) + delete m_SelRangePtrArr[i]; m_SelRangePtrArr.RemoveAll(); - if (nCount && m_Param.pEventSink) { + if (nCount && m_Param.pEventSink) m_Param.pEventSink->On_SelChanged(this); - } } + FX_BOOL CFDE_TxtEdtEngine::Redo(const CFX_ByteStringC& bsRedo) { if (IsLocked()) { return FALSE; @@ -906,8 +900,7 @@ void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) { ? ParagPosBgn.nParagIndex : (ParagPosBgn.nParagIndex + 1); for (i = nNextParagIndex; i <= ParagPosEnd.nParagIndex; i++) { - CFDE_TxtEdtParag* pParag = m_ParagPtrArray[nNextParagIndex]; - delete pParag; + delete m_ParagPtrArray[nNextParagIndex]; m_ParagPtrArray.RemoveAt(nNextParagIndex); } if (!(bLastParag && ParagPosBgn.nCharIndex == 0)) { @@ -980,17 +973,14 @@ void CFDE_TxtEdtEngine::RebuildParagraphs() { } while (pIter->Next()); pIter->Release(); } + void CFDE_TxtEdtEngine::RemoveAllParags() { int32_t nCount = m_ParagPtrArray.GetSize(); - int32_t i = 0; - for (i = 0; i < nCount; i++) { - CFDE_TxtEdtParag* pParag = m_ParagPtrArray[i]; - if (pParag) { - delete pParag; - } - } + for (int i = 0; i < nCount; ++i) + delete m_ParagPtrArray[i]; m_ParagPtrArray.RemoveAll(); } + void CFDE_TxtEdtEngine::RemoveAllPages() { int32_t nCount = m_PagePtrArray.GetSize(); int32_t i = 0; @@ -1610,8 +1600,7 @@ void CFDE_TxtEdtEngine::DeleteSelect() { int32_t nSelCount; while (nCountRange > 0) { nSelCount = GetSelRange(--nCountRange, nSelStart); - FDE_LPTXTEDTSELRANGE lpTemp = m_SelRangePtrArr[nCountRange]; - delete lpTemp; + delete m_SelRangePtrArr[nCountRange]; m_SelRangePtrArr.RemoveAt(nCountRange); DeleteRange_DoRecord(nSelStart, nSelCount, TRUE); } @@ -1622,6 +1611,7 @@ void CFDE_TxtEdtEngine::DeleteSelect() { return; } } + IFDE_TxtEdtDoRecord* IFDE_TxtEdtDoRecord::Create( const CFX_ByteStringC& bsDoRecord) { const FX_CHAR* lpBuf = bsDoRecord.c_str(); @@ -1632,10 +1622,10 @@ IFDE_TxtEdtDoRecord* IFDE_TxtEdtDoRecord::Create( case FDE_TXTEDT_DORECORD_DEL: return new CFDE_TxtEdtDoRecord_DeleteRange(bsDoRecord); default: - break; + return nullptr; } - return NULL; } + CFDE_TxtEdtDoRecord_Insert::CFDE_TxtEdtDoRecord_Insert( const CFX_ByteStringC& bsDoRecord) { Deserialize(bsDoRecord); diff --git a/xfa/fee/fde_txtedtpage.cpp b/xfa/fee/fde_txtedtpage.cpp index 5faafebd55..c50f66e2ff 100644 --- a/xfa/fee/fde_txtedtpage.cpp +++ b/xfa/fee/fde_txtedtpage.cpp @@ -139,21 +139,15 @@ CFDE_TxtEdtPage::CFDE_TxtEdtPage(IFDE_TxtEdtEngine* pEngine, int32_t nPageIndex) FXSYS_memset(&m_rtPageCanvas, 0, sizeof(CFX_RectF)); m_pEditEngine = (CFDE_TxtEdtEngine*)pEngine; } + CFDE_TxtEdtPage::~CFDE_TxtEdtPage() { m_PieceMassArr.RemoveAll(TRUE); - if (m_pTextSet) { - delete m_pTextSet; - m_pTextSet = NULL; - } - if (m_pCharWidth) { - delete[] m_pCharWidth; - m_pCharWidth = NULL; - } - if (m_pIter != NULL) { + delete m_pTextSet; + delete[] m_pCharWidth; + if (m_pIter) m_pIter->Release(); - m_pIter = NULL; - } } + void CFDE_TxtEdtPage::Release() { delete this; } @@ -555,32 +549,28 @@ int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox, m_bLoaded = TRUE; return 0; } + void CFDE_TxtEdtPage::UnloadPage(const CFX_RectF* pClipBox) { ASSERT(m_nRefCount > 0); m_nRefCount--; - if (m_nRefCount == 0) { - m_PieceMassArr.RemoveAll(); - if (m_pTextSet) { - delete m_pTextSet; - m_pTextSet = NULL; - } - if (m_pCharWidth) { - delete[] m_pCharWidth; - m_pCharWidth = NULL; - } - if (m_pBgnParag) { - m_pBgnParag->UnloadParag(); - } - if (m_pEndParag) { - m_pEndParag->UnloadParag(); - } - if (m_pIter) { - m_pIter->Release(); - m_pIter = NULL; - } - m_pBgnParag = NULL; - m_pEndParag = NULL; + if (m_nRefCount != 0) + return; + + m_PieceMassArr.RemoveAll(); + delete m_pTextSet; + m_pTextSet = nullptr; + delete[] m_pCharWidth; + m_pCharWidth = nullptr; + if (m_pBgnParag) + m_pBgnParag->UnloadParag(); + if (m_pEndParag) + m_pEndParag->UnloadParag(); + if (m_pIter) { + m_pIter->Release(); + m_pIter = nullptr; } + m_pBgnParag = nullptr; + m_pEndParag = nullptr; } const CFX_RectF& CFDE_TxtEdtPage::GetContentsBox() { diff --git a/xfa/fgas/font/fgas_stdfontmgr.cpp b/xfa/fgas/font/fgas_stdfontmgr.cpp index 54dd641319..e840cb2bdd 100644 --- a/xfa/fgas/font/fgas_stdfontmgr.cpp +++ b/xfa/fgas/font/fgas_stdfontmgr.cpp @@ -624,18 +624,14 @@ void CFX_FontMgrImp::Release() { uint32_t dwHash; CFX_FontDescriptorInfos* pDescs; m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs); - if (NULL != pDescs) { - delete pDescs; - } + delete pDescs; } pos = m_Hash2Fonts.GetStartPosition(); while (pos) { uint32_t dwHash; CFX_ArrayTemplate* pFonts; m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); - if (NULL != pFonts) { - delete pFonts; - } + delete pFonts; } m_Hash2Fonts.RemoveAll(); pos = m_Hash2FileAccess.GetStartPosition(); @@ -1207,9 +1203,7 @@ void CFX_FontMgrImp::ClearFontCache() { uint32_t dwHash; CFX_FontDescriptorInfos* pDescs; m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs); - if (NULL != pDescs) { - delete pDescs; - } + delete pDescs; } pos = m_FileAccess2IFXFont.GetStartPosition(); while (pos) { diff --git a/xfa/fwl/basewidget/fwl_caretimp.cpp b/xfa/fwl/basewidget/fwl_caretimp.cpp index 3cb2ed60f7..c61c459f2e 100644 --- a/xfa/fwl/basewidget/fwl_caretimp.cpp +++ b/xfa/fwl/basewidget/fwl_caretimp.cpp @@ -44,12 +44,11 @@ CFWL_CaretImp::CFWL_CaretImp(const CFWL_WidgetImpProperties& properties, m_pTimer = new CFWL_CaretTimer(this); SetStates(FWL_STATE_CAT_HightLight); } + CFWL_CaretImp::~CFWL_CaretImp() { - if (m_pTimer) { - delete m_pTimer; - m_pTimer = NULL; - } + delete m_pTimer; } + FWL_ERR CFWL_CaretImp::GetClassName(CFX_WideString& wsClass) const { wsClass = FWL_CLASS_Caret; return FWL_ERR_Succeeded; diff --git a/xfa/fwl/basewidget/fxmath_barcodeimp.cpp b/xfa/fwl/basewidget/fxmath_barcodeimp.cpp index 5ca0927671..5efd1621c8 100644 --- a/xfa/fwl/basewidget/fxmath_barcodeimp.cpp +++ b/xfa/fwl/basewidget/fxmath_barcodeimp.cpp @@ -46,13 +46,13 @@ static CBC_CodeBase* FX_Barcode_CreateBarCodeEngineObject(BC_TYPE type) { return NULL; } } + CFX_Barcode::CFX_Barcode() {} + CFX_Barcode::~CFX_Barcode() { - if (m_pBCEngine) { - delete m_pBCEngine; - m_pBCEngine = NULL; - } + delete m_pBCEngine; } + FX_BOOL CFX_Barcode::Create(BC_TYPE type) { m_pBCEngine = FX_Barcode_CreateBarCodeEngineObject(type); return m_pBCEngine != NULL; diff --git a/xfa/fwl/core/fwl_formimp.cpp b/xfa/fwl/core/fwl_formimp.cpp index 815aca974c..2fd85a8d0e 100644 --- a/xfa/fwl/core/fwl_formimp.cpp +++ b/xfa/fwl/core/fwl_formimp.cpp @@ -471,25 +471,19 @@ void CFWL_FormImp::ShowChildWidget(IFWL_Widget* pParent) { pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling); } } + void CFWL_FormImp::RemoveSysButtons() { m_rtCaption.Reset(); - if (m_pCloseBox) { - delete m_pCloseBox; - m_pCloseBox = NULL; - } - if (m_pMinBox) { - delete m_pMinBox; - m_pMinBox = NULL; - } - if (m_pMaxBox) { - delete m_pMaxBox; - m_pMaxBox = NULL; - } - if (m_pCaptionBox) { - delete m_pCaptionBox; - m_pCaptionBox = NULL; - } + delete m_pCloseBox; + m_pCloseBox = nullptr; + delete m_pMinBox; + m_pMinBox = nullptr; + delete m_pMaxBox; + m_pMaxBox = nullptr; + delete m_pCaptionBox; + m_pCaptionBox = nullptr; } + void CFWL_FormImp::CalcContentRect(CFX_RectF& rtContent) { #ifdef FWL_UseMacSystemBorder rtContent = m_rtRelative; diff --git a/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp index 267b2ca2ee..39afa783c0 100644 --- a/xfa/fwl/core/fwl_noteimp.cpp +++ b/xfa/fwl/core/fwl_noteimp.cpp @@ -870,20 +870,20 @@ CFWL_ToolTipContainer::~CFWL_ToolTipContainer() { } delete m_ToolTipDp; } + // static CFWL_ToolTipContainer* CFWL_ToolTipContainer::getInstance() { - if (!s_pInstance) { + if (!s_pInstance) s_pInstance = new CFWL_ToolTipContainer; - } return s_pInstance; } + // static void CFWL_ToolTipContainer::DeleteInstance() { - if (s_pInstance) { - delete s_pInstance; - s_pInstance = NULL; - } + delete s_pInstance; + s_pInstance = NULL; } + FX_ERR CFWL_ToolTipContainer::AddToolTipTarget(IFWL_ToolTipTarget* pTarget) { if (m_arrWidget.Find(pTarget) < 0) { m_arrWidget.Add(pTarget); diff --git a/xfa/fwl/core/fwl_widgetmgrimp.cpp b/xfa/fwl/core/fwl_widgetmgrimp.cpp index b1e0ca822a..0ce452edb0 100644 --- a/xfa/fwl/core/fwl_widgetmgrimp.cpp +++ b/xfa/fwl/core/fwl_widgetmgrimp.cpp @@ -39,6 +39,7 @@ CFWL_WidgetMgr::CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative) m_rtScreen.Reset(); #endif } + CFWL_WidgetMgr::~CFWL_WidgetMgr() { FX_POSITION ps = m_mapWidgetItem.GetStartPosition(); while (ps) { @@ -48,11 +49,9 @@ CFWL_WidgetMgr::~CFWL_WidgetMgr() { delete pItem; } m_mapWidgetItem.RemoveAll(); - if (m_pDelegate) { - delete m_pDelegate; - m_pDelegate = NULL; - } + delete m_pDelegate; } + int32_t CFWL_WidgetMgr::CountWidgets(IFWL_Widget* pParent) { CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); return TravelWidgetMgr(pParentItem, NULL, NULL); @@ -480,18 +479,18 @@ IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, } return parent; } + void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget* pForm, FX_FLOAT fx, FX_FLOAT fy) { - if (!FWL_UseOffscreen(pForm)) { + if (!FWL_UseOffscreen(pForm)) return; - } + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pForm); - if (pItem->pOffscreen) { - delete pItem->pOffscreen; - pItem->pOffscreen = NULL; - } + delete pItem->pOffscreen; + pItem->pOffscreen = nullptr; } + IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent, IFWL_Widget* focus, FX_BOOL& bFind) { diff --git a/xfa/fwl/theme/cfwl_checkboxtp.cpp b/xfa/fwl/theme/cfwl_checkboxtp.cpp index ccde660693..ac94c80d6d 100644 --- a/xfa/fwl/theme/cfwl_checkboxtp.cpp +++ b/xfa/fwl/theme/cfwl_checkboxtp.cpp @@ -22,21 +22,19 @@ #define CHECKBOX_COLOR_BOXRB1 (ArgbEncode(255, 241, 239, 226)) #define CHECKBOX_COLOR_BOXRB2 (ArgbEncode(255, 255, 255, 255)) -CFWL_CheckBoxTP::CFWL_CheckBoxTP() : m_pCheckPath(NULL) { - m_pThemeData = new CKBThemeData; +CFWL_CheckBoxTP::CFWL_CheckBoxTP() + : m_pThemeData(new CKBThemeData), m_pCheckPath(nullptr) { SetThemeData(0); } + CFWL_CheckBoxTP::~CFWL_CheckBoxTP() { - if (m_pThemeData) { - delete m_pThemeData; - m_pThemeData = NULL; - } + delete m_pThemeData; if (m_pCheckPath) { m_pCheckPath->Clear(); delete m_pCheckPath; - m_pCheckPath = NULL; } } + FX_BOOL CFWL_CheckBoxTP::IsValidWidget(IFWL_Widget* pWidget) { return pWidget && pWidget->GetClassID() == FWL_CLASSHASH_CheckBox; } diff --git a/xfa/fwl/theme/cfwl_formtp.cpp b/xfa/fwl/theme/cfwl_formtp.cpp index ec06f4ad24..4a18ea0cc4 100644 --- a/xfa/fwl/theme/cfwl_formtp.cpp +++ b/xfa/fwl/theme/cfwl_formtp.cpp @@ -35,30 +35,27 @@ CFWL_FormTP::CFWL_FormTP() : m_pActiveBitmap(NULL), m_pDeactivebitmap(NULL) { m_rtDisBBorder.Reset(); m_rtDisCaption.Reset(); } + CFWL_FormTP::~CFWL_FormTP() { - if (m_pThemeData) { - delete m_pThemeData; - m_pThemeData = NULL; - } + delete m_pThemeData; } + FWL_ERR CFWL_FormTP::Initialize() { InitTTO(); InitCaption(TRUE); InitCaption(FALSE); return CFWL_WidgetTP::Initialize(); } + FWL_ERR CFWL_FormTP::Finalize() { FinalizeTTO(); - if (m_pActiveBitmap) { - delete m_pActiveBitmap; - m_pActiveBitmap = NULL; - } - if (m_pDeactivebitmap) { - delete m_pDeactivebitmap; - m_pDeactivebitmap = NULL; - } + delete m_pActiveBitmap; + m_pActiveBitmap = nullptr; + delete m_pDeactivebitmap; + m_pDeactivebitmap = nullptr; return CFWL_WidgetTP::Finalize(); } + FX_BOOL CFWL_FormTP::IsValidWidget(IFWL_Widget* pWidget) { if (!pWidget) return FALSE; @@ -850,10 +847,7 @@ void CFWL_FormTP::InitCaption(FX_BOOL bActive) { CFX_Graphics gs; CFX_Path path; path.Create(); - if (m_pActiveBitmap) { - delete m_pActiveBitmap; - m_pActiveBitmap = NULL; - } + delete m_pActiveBitmap; m_pActiveBitmap = new CFX_DIBitmap; m_pActiveBitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb); dev.Attach(m_pActiveBitmap); @@ -875,10 +869,7 @@ void CFWL_FormTP::InitCaption(FX_BOOL bActive) { CFX_Graphics gs; CFX_Path path; path.Create(); - if (m_pDeactivebitmap) { - delete m_pDeactivebitmap; - m_pDeactivebitmap = NULL; - } + delete m_pDeactivebitmap; m_pDeactivebitmap = new CFX_DIBitmap; m_pDeactivebitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb); dev.Attach(m_pDeactivebitmap); diff --git a/xfa/fwl/theme/cfwl_pushbuttontp.cpp b/xfa/fwl/theme/cfwl_pushbuttontp.cpp index 5662ac09c2..780c580369 100644 --- a/xfa/fwl/theme/cfwl_pushbuttontp.cpp +++ b/xfa/fwl/theme/cfwl_pushbuttontp.cpp @@ -15,15 +15,14 @@ #define PUSHBUTTON_SIZE_Corner 2 -CFWL_PushButtonTP::CFWL_PushButtonTP() { - m_pThemeData = new PBThemeData; +CFWL_PushButtonTP::CFWL_PushButtonTP() : m_pThemeData(new PBThemeData) { SetThemeData(0); } + CFWL_PushButtonTP::~CFWL_PushButtonTP() { - if (m_pThemeData) { - delete m_pThemeData; - } + delete m_pThemeData; } + FX_BOOL CFWL_PushButtonTP::IsValidWidget(IFWL_Widget* pWidget) { return pWidget->GetClassID() == FWL_CLASSHASH_PushButton; } diff --git a/xfa/fwl/theme/cfwl_scrollbartp.cpp b/xfa/fwl/theme/cfwl_scrollbartp.cpp index 11326edf59..0913a8daa2 100644 --- a/xfa/fwl/theme/cfwl_scrollbartp.cpp +++ b/xfa/fwl/theme/cfwl_scrollbartp.cpp @@ -15,16 +15,14 @@ #define FWL_SCROLL_PawLen 12.5f -CFWL_ScrollBarTP::CFWL_ScrollBarTP() { - m_pThemeData = new SBThemeData; +CFWL_ScrollBarTP::CFWL_ScrollBarTP() : m_pThemeData(new SBThemeData) { SetThemeData(0); } + CFWL_ScrollBarTP::~CFWL_ScrollBarTP() { - if (m_pThemeData) { - delete m_pThemeData; - m_pThemeData = NULL; - } + delete m_pThemeData; } + FX_BOOL CFWL_ScrollBarTP::IsValidWidget(IFWL_Widget* pWidget) { if (!pWidget) return FALSE; diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp index 7f4e547e24..1ff241636f 100644 --- a/xfa/fwl/theme/cfwl_widgettp.cpp +++ b/xfa/fwl/theme/cfwl_widgettp.cpp @@ -741,27 +741,26 @@ uint32_t FWL_GetThemeColor(uint32_t dwThemeID) { } CFWL_ArrowData* CFWL_ArrowData::m_pInstance = NULL; + CFWL_ArrowData* CFWL_ArrowData::GetInstance() { - if (!m_pInstance) { + if (!m_pInstance) m_pInstance = new CFWL_ArrowData; - } return m_pInstance; } + FX_BOOL CFWL_ArrowData::IsInstance() { - return (m_pInstance != NULL); + return !!m_pInstance; } + void CFWL_ArrowData::DestroyInstance() { - if (m_pInstance) { - delete m_pInstance; - m_pInstance = NULL; - } + delete m_pInstance; + m_pInstance = nullptr; } + CFWL_ArrowData::~CFWL_ArrowData() { - if (m_pColorData) { - delete m_pColorData; - m_pColorData = NULL; - } + delete m_pColorData; } + void CFWL_ArrowData::SetColorData(uint32_t dwID) { if (!m_pColorData) { m_pColorData = new CColorData; diff --git a/xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp b/xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp index c39d3c6eb0..982cc9c4ad 100644 --- a/xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp +++ b/xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp @@ -20,6 +20,8 @@ * limitations under the License. */ +#include + #include "core/fxcodec/codec/include/ccodec_progressivedecoder.h" #include "core/fxcodec/include/fx_codec.h" #include "xfa/fxbarcode/BC_BufferedImageLuminanceSource.h" @@ -32,60 +34,35 @@ class CBC_Pause : public IFX_Pause { }; static CFX_DIBitmap* CreateDIBSource(IFX_FileRead* fileread) { - CFX_DIBitmap* bitmap = nullptr; - CCodec_ModuleMgr* pCodecMgr = nullptr; - CCodec_ProgressiveDecoder* pImageCodec = nullptr; - pCodecMgr = new CCodec_ModuleMgr(); - pImageCodec = pCodecMgr->CreateProgressiveDecoder(); + std::unique_ptr pCodecMgr(new CCodec_ModuleMgr()); + std::unique_ptr pImageCodec( + pCodecMgr->CreateProgressiveDecoder()); FXCODEC_STATUS status = FXCODEC_STATUS_DECODE_FINISH; status = pImageCodec->LoadImageInfo(fileread, FXCODEC_IMAGE_UNKNOWN, nullptr); if (status != FXCODEC_STATUS_FRAME_READY) return nullptr; - bitmap = new CFX_DIBitmap; + std::unique_ptr bitmap(new CFX_DIBitmap); bitmap->Create(pImageCodec->GetWidth(), pImageCodec->GetHeight(), FXDIB_Argb); bitmap->Clear(FXARGB_MAKE(0xFF, 0xFF, 0xFF, 0xFF)); CBC_Pause pause; int32_t frames; status = pImageCodec->GetFrames(frames, &pause); - while (status == FXCODEC_STATUS_FRAME_TOBECONTINUE) { + while (status == FXCODEC_STATUS_FRAME_TOBECONTINUE) status = pImageCodec->GetFrames(frames, &pause); - } - if (status != FXCODEC_STATUS_DECODE_READY) { - goto except; - } - status = pImageCodec->StartDecode(bitmap, 0, 0, bitmap->GetWidth(), + + if (status != FXCODEC_STATUS_DECODE_READY) + return nullptr; + + status = pImageCodec->StartDecode(bitmap.get(), 0, 0, bitmap->GetWidth(), bitmap->GetHeight(), 0, FALSE); - if (status == FXCODEC_STATUS_ERR_PARAMS) { - goto except; - } - if (status != FXCODEC_STATUS_DECODE_TOBECONTINUE) { - goto except; - } - while (status == FXCODEC_STATUS_DECODE_TOBECONTINUE) { + if (status != FXCODEC_STATUS_DECODE_TOBECONTINUE) + return nullptr; + + while (status == FXCODEC_STATUS_DECODE_TOBECONTINUE) status = pImageCodec->ContinueDecode(&pause); - } - if (status != FXCODEC_STATUS_DECODE_FINISH) { - goto except; - } - if (pImageCodec) { - delete pImageCodec; - pImageCodec = nullptr; - } - delete pCodecMgr; - pCodecMgr = nullptr; - return bitmap; -except: - if (pImageCodec) { - delete pImageCodec; - pImageCodec = nullptr; - } - delete pCodecMgr; - pCodecMgr = nullptr; - if (bitmap) { - delete bitmap; - } - return nullptr; + + return status == FXCODEC_STATUS_DECODE_FINISH ? bitmap.release() : nullptr; } CBC_BufferedImageLuminanceSource::CBC_BufferedImageLuminanceSource( diff --git a/xfa/fxbarcode/BC_TwoDimWriter.cpp b/xfa/fxbarcode/BC_TwoDimWriter.cpp index f0065a02b9..a844bf1c42 100644 --- a/xfa/fxbarcode/BC_TwoDimWriter.cpp +++ b/xfa/fxbarcode/BC_TwoDimWriter.cpp @@ -53,6 +53,7 @@ void CBC_TwoDimWriter::RenderDeviceResult(CFX_RenderDevice* device, } } } + void CBC_TwoDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, int32_t& e) { if (m_bFixedSize) { @@ -80,12 +81,11 @@ void CBC_TwoDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, } if (!m_bFixedSize) { CFX_DIBitmap* pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height); - if (pOutBitmap) { - delete pOutBitmap; - } + delete pOutBitmap; pOutBitmap = pStretchBitmap; } } + void CBC_TwoDimWriter::RenderResult(uint8_t* code, int32_t codeWidth, int32_t codeHeight, diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp index 5e9fd33ac4..33771418d4 100644 --- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp +++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp @@ -31,16 +31,14 @@ void CBC_ReedSolomonGF256::Initialize() { DataMatrixField = new CBC_ReedSolomonGF256(0x012D); DataMatrixField->Init(); } + void CBC_ReedSolomonGF256::Finalize() { - if (QRCodeFild) { - delete QRCodeFild; - } - QRCodeFild = NULL; - if (DataMatrixField) { - delete DataMatrixField; - } - DataMatrixField = NULL; + delete QRCodeFild; + QRCodeFild = nullptr; + delete DataMatrixField; + DataMatrixField = nullptr; } + CBC_ReedSolomonGF256::CBC_ReedSolomonGF256(int32_t primitive) { int32_t x = 1; for (int32_t j = 0; j < 256; j++) { diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp index b95c2be283..ae1b237957 100644 --- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp @@ -290,6 +290,7 @@ void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents, } FX_Free(pCharPos); } + void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, const CFX_WideStringC& contents, int32_t& e) { @@ -319,11 +320,10 @@ void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, BC_EXCEPTION_CHECK_ReturnVoid(e); } CFX_DIBitmap* pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height); - if (pOutBitmap) { - delete pOutBitmap; - } + delete pOutBitmap; pOutBitmap = pStretchBitmap; } + void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device, const CFX_Matrix* matrix, const CFX_WideStringC& contents, diff --git a/xfa/fxbarcode/pdf417/BC_PDF417.cpp b/xfa/fxbarcode/pdf417/BC_PDF417.cpp index 15b448b37b..908901c04e 100644 --- a/xfa/fxbarcode/pdf417/BC_PDF417.cpp +++ b/xfa/fxbarcode/pdf417/BC_PDF417.cpp @@ -401,11 +401,11 @@ CBC_PDF417::CBC_PDF417(FX_BOOL compact) { m_minRows = 3; m_barcodeMatrix = NULL; } + CBC_PDF417::~CBC_PDF417() { - if (m_barcodeMatrix) { - delete m_barcodeMatrix; - } + delete m_barcodeMatrix; } + CBC_BarcodeMatrix* CBC_PDF417::getBarcodeMatrix() { return m_barcodeMatrix; } @@ -556,9 +556,7 @@ CFX_Int32Array* CBC_PDF417::determineDimensions( continue; } ratio = newRatio; - if (dimension) { - delete dimension; - } + delete dimension; dimension = new CFX_Int32Array; dimension->Add(cols); dimension->Add(rows); diff --git a/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp b/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp index c8328ab1c6..d2ad98e408 100644 --- a/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp +++ b/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp @@ -42,20 +42,14 @@ CBC_BoundingBox::CBC_BoundingBox(CBC_BoundingBox* boundingBox) { init(boundingBox->m_image, boundingBox->m_topLeft, boundingBox->m_bottomLeft, boundingBox->m_topRight, boundingBox->m_bottomRight); } + CBC_BoundingBox::~CBC_BoundingBox() { - if (m_topLeft) { - delete m_topLeft; - } - if (m_bottomLeft) { - delete m_bottomLeft; - } - if (m_topRight) { - delete m_topRight; - } - if (m_bottomRight) { - delete m_bottomRight; - } + delete m_topLeft; + delete m_bottomLeft; + delete m_topRight; + delete m_bottomRight; } + CBC_BoundingBox* CBC_BoundingBox::merge(CBC_BoundingBox* leftBox, CBC_BoundingBox* rightBox, int32_t& e) { diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp b/xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp index cfd52e56dc..345efd5648 100644 --- a/xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp +++ b/xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp @@ -114,9 +114,7 @@ CFX_PtrArray* CBC_Detector::detect(FX_BOOL multiple, CFX_PtrArray* vertices = findVertices(bitMatrix, row, column); if (vertices->GetAt(0) == NULL && vertices->GetAt(3) == NULL) { if (!foundBarcodeInRow) { - if (vertices) { - delete (vertices); - } + delete vertices; break; } foundBarcodeInRow = FALSE; @@ -132,9 +130,7 @@ CFX_PtrArray* CBC_Detector::detect(FX_BOOL multiple, } } row += ROW_STEP; - if (vertices) { - delete (vertices); - } + delete vertices; continue; } foundBarcodeInRow = TRUE; diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp b/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp index 830b65e199..2c96f7005f 100644 --- a/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp +++ b/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp @@ -153,32 +153,20 @@ CFX_PtrArray* CBC_PDF417ECErrorCorrection::runEuclideanAlgorithm( n = j; if (rLast->isZero()) { e = BCExceptionChecksumException; - if (qtemp) { - delete qtemp; - } - if (rtemp) { - delete rtemp; - } - if (ttemp) { - delete ttemp; - } - return NULL; + delete qtemp; + delete rtemp; + delete ttemp; + return nullptr; } r = rLastLast; CBC_PDF417ECModulusPoly* q = m_field->getZero(); int32_t denominatorLeadingTerm = rLast->getCoefficient(rLast->getDegree()); int32_t dltInverse = m_field->inverse(denominatorLeadingTerm, e); if (e != BCExceptionNO) { - if (qtemp) { - delete qtemp; - } - if (rtemp) { - delete rtemp; - } - if (ttemp) { - delete ttemp; - } - return NULL; + delete qtemp; + delete rtemp; + delete ttemp; + return nullptr; } while (r->getDegree() >= rLast->getDegree() && !r->isZero()) { int32_t degreeDiff = r->getDegree() - rLast->getDegree(); @@ -187,81 +175,51 @@ CFX_PtrArray* CBC_PDF417ECErrorCorrection::runEuclideanAlgorithm( CBC_PDF417ECModulusPoly* buildmonomial = m_field->buildMonomial(degreeDiff, scale, e); if (e != BCExceptionNO) { - if (qtemp) { - delete qtemp; - } - if (rtemp) { - delete rtemp; - } - if (ttemp) { - delete ttemp; - } - return NULL; + delete qtemp; + delete rtemp; + delete ttemp; + return nullptr; } q = q->add(buildmonomial, e); delete buildmonomial; - if (qtemp) { - delete qtemp; - } + delete qtemp; if (e != BCExceptionNO) { - if (rtemp) { - delete rtemp; - } - if (ttemp) { - delete ttemp; - } - return NULL; + delete rtemp; + delete ttemp; + return nullptr; } qtemp = q; CBC_PDF417ECModulusPoly* multiply = rLast->multiplyByMonomial(degreeDiff, scale, e); if (e != BCExceptionNO) { - if (qtemp) { - delete qtemp; - } - if (rtemp) { - delete rtemp; - } - if (ttemp) { - delete ttemp; - } - return NULL; + delete qtemp; + delete rtemp; + delete ttemp; + return nullptr; } CBC_PDF417ECModulusPoly* temp = r; r = temp->subtract(multiply, e); delete multiply; if (m > 1 && i > m) { delete temp; - temp = NULL; + temp = nullptr; } if (e != BCExceptionNO) { - if (qtemp) { - delete qtemp; - } - if (rtemp) { - delete rtemp; - } - if (ttemp) { - delete ttemp; - } - return NULL; + delete qtemp; + delete rtemp; + delete ttemp; + return nullptr; } rtemp = r; i = m + 1; } ttemp = q->multiply(tLast, e); - if (qtemp) { - delete qtemp; - qtemp = NULL; - } + delete qtemp; + qtemp = nullptr; if (e != BCExceptionNO) { - if (rtemp) { - delete rtemp; - } - if (ttemp) { - delete ttemp; - } - return NULL; + delete rtemp; + delete ttemp; + return nullptr; } t = ttemp->subtract(tLastLast, e); if (n > 1 && j > n) { @@ -269,19 +227,15 @@ CFX_PtrArray* CBC_PDF417ECErrorCorrection::runEuclideanAlgorithm( } delete ttemp; if (e != BCExceptionNO) { - if (rtemp) { - delete rtemp; - } - return NULL; + delete rtemp; + return nullptr; } ttemp = t; t = ttemp->negative(e); delete ttemp; if (e != BCExceptionNO) { - if (rtemp) { - delete rtemp; - } - return NULL; + delete rtemp; + return nullptr; } ttemp = t; j++; @@ -289,38 +243,24 @@ CFX_PtrArray* CBC_PDF417ECErrorCorrection::runEuclideanAlgorithm( int32_t sigmaTildeAtZero = t->getCoefficient(0); if (sigmaTildeAtZero == 0) { e = BCExceptionChecksumException; - if (rtemp) { - delete rtemp; - } - if (ttemp) { - delete ttemp; - } - return NULL; + delete rtemp; + delete ttemp; + return nullptr; } int32_t inverse = m_field->inverse(sigmaTildeAtZero, e); if (e != BCExceptionNO) { - if (rtemp) { - delete rtemp; - } - if (ttemp) { - delete ttemp; - } - return NULL; - } - CBC_PDF417ECModulusPoly* sigma = t->multiply(inverse, e); - if (ttemp) { + delete rtemp; delete ttemp; + return nullptr; } + CBC_PDF417ECModulusPoly* sigma = t->multiply(inverse, e); + delete ttemp; if (e != BCExceptionNO) { - if (rtemp) { - delete rtemp; - } - return NULL; - } - CBC_PDF417ECModulusPoly* omega = r->multiply(inverse, e); - if (rtemp) { delete rtemp; + return nullptr; } + CBC_PDF417ECModulusPoly* omega = r->multiply(inverse, e); + delete rtemp; BC_EXCEPTION_CHECK_ReturnValue(e, NULL); CFX_PtrArray* modulusPoly = new CFX_PtrArray; modulusPoly->Add(sigma); diff --git a/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp b/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp index 716b6c17de..fc87785d5c 100644 --- a/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp +++ b/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp @@ -93,14 +93,10 @@ CFX_ByteString CBC_QRCodeReader::Decode(CBC_BinaryBitmap* image, int32_t& e) { return bs; } void CBC_QRCodeReader::ReleaseAll() { - if (CBC_ReedSolomonGF256::QRCodeFild) { - delete CBC_ReedSolomonGF256::QRCodeFild; - CBC_ReedSolomonGF256::QRCodeFild = NULL; - } - if (CBC_ReedSolomonGF256::DataMatrixField) { - delete CBC_ReedSolomonGF256::DataMatrixField; - CBC_ReedSolomonGF256::DataMatrixField = NULL; - } + delete CBC_ReedSolomonGF256::QRCodeFild; + CBC_ReedSolomonGF256::QRCodeFild = nullptr; + delete CBC_ReedSolomonGF256::DataMatrixField; + CBC_ReedSolomonGF256::DataMatrixField = nullptr; CBC_QRCoderMode::Destroy(); CBC_QRCoderErrorCorrectionLevel::Destroy(); CBC_QRDataMask::Destroy(); diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp index d58b594e27..cd48a43a0e 100644 --- a/xfa/fxfa/app/xfa_ffdocview.cpp +++ b/xfa/fxfa/app/xfa_ffdocview.cpp @@ -62,13 +62,12 @@ CXFA_FFDocView::CXFA_FFDocView(CXFA_FFDoc* pDoc) m_pOldFocusWidget(nullptr), m_iStatus(XFA_DOCVIEW_LAYOUTSTATUS_None), m_iLock(0) {} + CXFA_FFDocView::~CXFA_FFDocView() { DestroyDocView(); - if (m_pWidgetHandler) { - delete m_pWidgetHandler; - } - m_pWidgetHandler = NULL; + delete m_pWidgetHandler; } + void CXFA_FFDocView::InitLayout(CXFA_Node* pNode) { RunBindItems(); ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Initialize); diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp index 3893bc29fb..6db2b7078c 100644 --- a/xfa/fxfa/app/xfa_ffpushbutton.cpp +++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp @@ -86,25 +86,19 @@ void CXFA_FFPushButton::UpdateWidgetProperty() { } m_pNormalWidget->ModifyStylesEx(dwStyleEx, 0xFFFFFFFF); } + void CXFA_FFPushButton::UnloadWidget() { - if (m_pRolloverTextLayout) { - delete m_pRolloverTextLayout; - m_pRolloverTextLayout = NULL; - } - if (m_pDownTextLayout) { - delete m_pDownTextLayout; - m_pDownTextLayout = NULL; - } - if (m_pDownProvider) { - delete m_pDownProvider; - m_pDownProvider = NULL; - } - if (m_pRollProvider) { - delete m_pRollProvider; - m_pRollProvider = NULL; - } + delete m_pRolloverTextLayout; + m_pRolloverTextLayout = nullptr; + delete m_pDownTextLayout; + m_pDownTextLayout = nullptr; + delete m_pDownProvider; + m_pDownProvider = nullptr; + delete m_pRollProvider; + m_pRollProvider = nullptr; CXFA_FFField::UnloadWidget(); } + FX_BOOL CXFA_FFPushButton::PerformLayout() { CXFA_FFWidget::PerformLayout(); CFX_RectF rtWidget; diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index 34b29c79d2..c1af34c030 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -526,17 +526,14 @@ CXFA_ImageRenderer::CXFA_ImageRenderer() { m_Result = TRUE; m_bPrint = FALSE; } + CXFA_ImageRenderer::~CXFA_ImageRenderer() { - if (m_pCloneConvert) { - delete m_pCloneConvert; - } - if (m_pTransformer) { - delete m_pTransformer; - } - if (m_DeviceHandle) { + delete m_pCloneConvert; + delete m_pTransformer; + if (m_DeviceHandle) m_pDevice->CancelDIBits(m_DeviceHandle); - } } + FX_BOOL CXFA_ImageRenderer::Start(CFX_RenderDevice* pDevice, CFX_DIBSource* pDIBSource, FX_ARGB bitmap_argb, diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp index f2479b7d2f..9ed84e1604 100644 --- a/xfa/fxfa/app/xfa_textlayout.cpp +++ b/xfa/fxfa/app/xfa_textlayout.cpp @@ -996,6 +996,7 @@ int32_t CXFA_TextLayout::CountBlocks() const { int32_t iCount = m_Blocks.GetSize() / 2; return iCount > 0 ? iCount : 1; } + FX_BOOL CXFA_TextLayout::CalcSize(const CFX_SizeF& minSize, const CFX_SizeF& maxSize, CFX_SizeF& defaultSize) { @@ -1014,13 +1015,12 @@ FX_BOOL CXFA_TextLayout::CalcSize(const CFX_SizeF& minSize, if (fLinePos < 0.1f) { fLinePos = m_textParser.GetFontSize(m_pTextProvider, NULL); } - if (m_pTabstopContext) { - delete m_pTabstopContext; - m_pTabstopContext = NULL; - } + delete m_pTabstopContext; + m_pTabstopContext = nullptr; defaultSize = CFX_SizeF(m_fMaxWidth, fLinePos); return TRUE; } + FX_BOOL CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) { if (size.x < 1) { return FALSE; @@ -1035,15 +1035,13 @@ FX_BOOL CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) { FX_FLOAT fLinePos = 0; Loader(size, fLinePos, TRUE); UpdateAlign(size.y, fLinePos); - if (m_pTabstopContext) { - delete m_pTabstopContext; - m_pTabstopContext = NULL; - } - if (fHeight) { + delete m_pTabstopContext; + m_pTabstopContext = nullptr; + if (fHeight) *fHeight = fLinePos; - } return TRUE; } + FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { if (m_pLoader == NULL || iBlock < 0 || iBlock >= CountBlocks()) { return FALSE; diff --git a/xfa/fxfa/parser/xfa_document_imp.cpp b/xfa/fxfa/parser/xfa_document_imp.cpp index ad3fd70e0d..083fe24a7e 100644 --- a/xfa/fxfa/parser/xfa_document_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_imp.cpp @@ -45,44 +45,31 @@ CXFA_Document::~CXFA_Document() { delete m_pRootNode; PurgeNodes(); } + void CXFA_Document::ClearLayoutData() { - if (m_pLayoutProcessor) { - delete m_pLayoutProcessor; - m_pLayoutProcessor = NULL; - } + delete m_pLayoutProcessor; + m_pLayoutProcessor = nullptr; + if (m_pScriptContext) { m_pScriptContext->Release(); - m_pScriptContext = NULL; - } - if (m_pLocalMgr) { - delete m_pLocalMgr; - m_pLocalMgr = NULL; - } - if (m_pScriptDataWindow) { - delete m_pScriptDataWindow; - m_pScriptDataWindow = NULL; - } - if (m_pScriptEvent) { - delete m_pScriptEvent; - m_pScriptEvent = NULL; - } - if (m_pScriptHost) { - delete m_pScriptHost; - m_pScriptHost = NULL; - } - if (m_pScriptLog) { - delete m_pScriptLog; - m_pScriptLog = NULL; - } - if (m_pScriptLayout) { - delete m_pScriptLayout; - m_pScriptLayout = NULL; - } - if (m_pScriptSignature) { - delete m_pScriptSignature; - m_pScriptSignature = NULL; - } + m_pScriptContext = nullptr; + } + delete m_pLocalMgr; + m_pLocalMgr = nullptr; + delete m_pScriptDataWindow; + m_pScriptDataWindow = nullptr; + delete m_pScriptEvent; + m_pScriptEvent = nullptr; + delete m_pScriptHost; + m_pScriptHost = nullptr; + delete m_pScriptLog; + m_pScriptLog = nullptr; + delete m_pScriptLayout; + m_pScriptLayout = nullptr; + delete m_pScriptSignature; + m_pScriptSignature = nullptr; } + void CXFA_Document::SetRoot(CXFA_Node* pNewRoot) { if (m_pRootNode) { AddPurgeNode(m_pRootNode); diff --git a/xfa/fxfa/parser/xfa_document_layout_imp.cpp b/xfa/fxfa/parser/xfa_document_layout_imp.cpp index 9b9a879d4d..44d053b8c2 100644 --- a/xfa/fxfa/parser/xfa_document_layout_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_layout_imp.cpp @@ -42,14 +42,13 @@ CXFA_LayoutProcessor::~CXFA_LayoutProcessor() { CXFA_Document* CXFA_LayoutProcessor::GetDocument() const { return m_pDocument; } + int32_t CXFA_LayoutProcessor::StartLayout(FX_BOOL bForceRestart) { - if (!bForceRestart && !IsNeedLayout()) { + if (!bForceRestart && !IsNeedLayout()) return 100; - } - if (m_pRootItemLayoutProcessor) { - delete m_pRootItemLayoutProcessor; - m_pRootItemLayoutProcessor = NULL; - } + + delete m_pRootItemLayoutProcessor; + m_pRootItemLayoutProcessor = nullptr; m_nProgressCounter = 0; CXFA_Node* pFormPacketNode = ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)); @@ -147,17 +146,15 @@ void CXFA_LayoutProcessor::AddChangedContainer(CXFA_Node* pContainer) { CXFA_ContainerLayoutItem* CXFA_LayoutProcessor::GetRootLayoutItem() const { return m_pLayoutPageMgr ? m_pLayoutPageMgr->GetRootLayoutItem() : NULL; } + void CXFA_LayoutProcessor::ClearLayoutData() { - if (m_pLayoutPageMgr) { - delete m_pLayoutPageMgr; - m_pLayoutPageMgr = NULL; - } - if (m_pRootItemLayoutProcessor) { - delete m_pRootItemLayoutProcessor; - m_pRootItemLayoutProcessor = NULL; - } + delete m_pLayoutPageMgr; + m_pLayoutPageMgr = nullptr; + delete m_pRootItemLayoutProcessor; + m_pRootItemLayoutProcessor = nullptr; m_nProgressCounter = 0; } + FX_BOOL CXFA_LayoutProcessor::IsNeedLayout() { return m_bNeeLayout || m_rgChangedContainers.GetSize() > 0; } diff --git a/xfa/fxfa/parser/xfa_locale.cpp b/xfa/fxfa/parser/xfa_locale.cpp index ee6d289a25..ff0371bc88 100644 --- a/xfa/fxfa/parser/xfa_locale.cpp +++ b/xfa/fxfa/parser/xfa_locale.cpp @@ -21,14 +21,13 @@ static const FX_WCHAR g_FX_Currency[] = L"$z,zzz,zzz,zzz,zzz,zz9.99"; static const FX_WCHAR g_FX_Decimal[] = L"z,zzz,zzz,zzz,zzz,zz9.zzz"; static const FX_WCHAR g_FX_Integer[] = L"z,zzz,zzz,zzz,zzz,zzz"; -CXFA_XMLLocale::CXFA_XMLLocale(CXML_Element* pLocaleData) { - m_pLocaleData = pLocaleData; -} +CXFA_XMLLocale::CXFA_XMLLocale(CXML_Element* pLocaleData) + : m_pLocaleData(pLocaleData) {} + CXFA_XMLLocale::~CXFA_XMLLocale() { - if (m_pLocaleData) { - delete m_pLocaleData; - } + delete m_pLocaleData; } + void CXFA_XMLLocale::Release() { delete this; } diff --git a/xfa/fxfa/parser/xfa_parser_imp.cpp b/xfa/fxfa/parser/xfa_parser_imp.cpp index 7eef2bd403..23a8dbc925 100644 --- a/xfa/fxfa/parser/xfa_parser_imp.cpp +++ b/xfa/fxfa/parser/xfa_parser_imp.cpp @@ -1390,13 +1390,13 @@ void CXFA_DocumentParser::ConstructXFANode(CXFA_Node* pXFANode, m_pDocument->SetRoot(pRootNode); } } + void CXFA_DocumentParser::CloseParser() { - if (m_pDocument) { - delete m_pDocument; - m_pDocument = NULL; - } + delete m_pDocument; + m_pDocument = nullptr; m_nodeParser.CloseParser(); } + CXFA_XMLParser::CXFA_XMLParser(CFDE_XMLNode* pRoot, IFX_Stream* pStream) : m_nElementStart(0), m_dwCheckStatus(0), diff --git a/xfa/fxfa/parser/xfa_script_imp.cpp b/xfa/fxfa/parser/xfa_script_imp.cpp index ea16fd1e7c..1cd5689045 100644 --- a/xfa/fxfa/parser/xfa_script_imp.cpp +++ b/xfa/fxfa/parser/xfa_script_imp.cpp @@ -53,10 +53,7 @@ CXFA_ScriptContext::~CXFA_ScriptContext() { FXJSE_Context_Release(m_hJsContext); m_hJsContext = NULL; } - if (m_pResolveProcessor) { - delete m_pResolveProcessor; - m_pResolveProcessor = NULL; - } + delete m_pResolveProcessor; m_upObjectArray.RemoveAll(); for (int32_t i = 0; i < m_CacheListArray.GetSize(); i++) delete m_CacheListArray[i]; @@ -398,29 +395,29 @@ void CXFA_ScriptContext::DefineJsContext() { FXJSE_HCONTEXT CXFA_ScriptContext::CreateVariablesContext( CXFA_Node* pScriptNode, CXFA_Node* pSubform) { - if (pScriptNode == NULL || pSubform == NULL) { - return NULL; - } + if (!pScriptNode || !pSubform) + return nullptr; + if (m_mapVariableToHValue.GetCount() == 0) { - m_JsGlobalVariablesClass.constructor = NULL; + m_JsGlobalVariablesClass.constructor = nullptr; m_JsGlobalVariablesClass.name = "XFAScriptObject"; m_JsGlobalVariablesClass.propNum = 0; - m_JsGlobalVariablesClass.properties = NULL; + m_JsGlobalVariablesClass.properties = nullptr; m_JsGlobalVariablesClass.methNum = 0; - m_JsGlobalVariablesClass.methods = NULL; + m_JsGlobalVariablesClass.methods = nullptr; m_JsGlobalVariablesClass.dynPropGetter = CXFA_ScriptContext::GlobalPropertyGetter; m_JsGlobalVariablesClass.dynPropSetter = CXFA_ScriptContext::GlobalPropertySetter; m_JsGlobalVariablesClass.dynPropTypeGetter = CXFA_ScriptContext::NormalPropTypeGetter; - m_JsGlobalVariablesClass.dynPropDeleter = NULL; + m_JsGlobalVariablesClass.dynPropDeleter = nullptr; m_JsGlobalVariablesClass.dynMethodCall = CXFA_ScriptContext::NormalMethodCall; } - CXFA_ThisProxy* lpVariableNode = new CXFA_ThisProxy(pSubform, pScriptNode); - FXJSE_HCONTEXT hVariablesContext = FXJSE_Context_Create( - m_hJsRuntime, &m_JsGlobalVariablesClass, (CXFA_Object*)lpVariableNode); + FXJSE_HCONTEXT hVariablesContext = + FXJSE_Context_Create(m_hJsRuntime, &m_JsGlobalVariablesClass, + new CXFA_ThisProxy(pSubform, pScriptNode)); RemoveBuiltInObjs(hVariablesContext); FXJSE_Context_EnableCompatibleMode( hVariablesContext, FXJSE_COMPATIBLEMODEFLAG_CONSTRUCTOREXTRAMETHODS); @@ -435,97 +432,96 @@ CXFA_Object* CXFA_ScriptContext::GetVariablesThis(CXFA_Object* pObject, } return pObject; } + FX_BOOL CXFA_ScriptContext::RunVariablesScript(CXFA_Node* pScriptNode) { - if (pScriptNode == NULL) { + if (!pScriptNode) return FALSE; - } - if (pScriptNode->GetClassID() == XFA_ELEMENT_Script) { - CXFA_Node* pParent = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent); - if (!pParent || pParent->GetClassID() != XFA_ELEMENT_Variables) { - return FALSE; - } - if (m_mapVariableToHValue.GetValueAt(pScriptNode)) { - return TRUE; - } - CXFA_Node* pTextNode = pScriptNode->GetNodeItem(XFA_NODEITEM_FirstChild); - if (!pTextNode) { - return FALSE; - } - CFX_WideStringC wsScript; - if (!pTextNode->TryCData(XFA_ATTRIBUTE_Value, wsScript)) { - return FALSE; - } - CFX_ByteString btScript = - FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength()); - FXJSE_HVALUE hRetValue = FXJSE_Value_Create(m_hJsRuntime); - CXFA_Node* pThisObject = pParent->GetNodeItem(XFA_NODEITEM_Parent); - FXJSE_HCONTEXT hVariablesContext = - CreateVariablesContext(pScriptNode, pThisObject); - CXFA_Object* pOriginalObject = m_pThisObject; - m_pThisObject = pThisObject; - FX_BOOL bRet = - FXJSE_ExecuteScript(hVariablesContext, btScript.c_str(), hRetValue); - m_pThisObject = pOriginalObject; - FXJSE_Value_Release(hRetValue); - return bRet; - } - return TRUE; + + if (pScriptNode->GetClassID() != XFA_ELEMENT_Script) + return TRUE; + + CXFA_Node* pParent = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent); + if (!pParent || pParent->GetClassID() != XFA_ELEMENT_Variables) + return FALSE; + + if (m_mapVariableToHValue.GetValueAt(pScriptNode)) + return TRUE; + + CXFA_Node* pTextNode = pScriptNode->GetNodeItem(XFA_NODEITEM_FirstChild); + if (!pTextNode) + return FALSE; + + CFX_WideStringC wsScript; + if (!pTextNode->TryCData(XFA_ATTRIBUTE_Value, wsScript)) + return FALSE; + + CFX_ByteString btScript = + FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength()); + FXJSE_HVALUE hRetValue = FXJSE_Value_Create(m_hJsRuntime); + CXFA_Node* pThisObject = pParent->GetNodeItem(XFA_NODEITEM_Parent); + FXJSE_HCONTEXT hVariablesContext = + CreateVariablesContext(pScriptNode, pThisObject); + CXFA_Object* pOriginalObject = m_pThisObject; + m_pThisObject = pThisObject; + FX_BOOL bRet = + FXJSE_ExecuteScript(hVariablesContext, btScript.c_str(), hRetValue); + m_pThisObject = pOriginalObject; + FXJSE_Value_Release(hRetValue); + return bRet; } + FX_BOOL CXFA_ScriptContext::QueryVariableHValue( CXFA_Node* pScriptNode, const CFX_ByteStringC& szPropName, FXJSE_HVALUE hValue, FX_BOOL bGetter) { - if (!pScriptNode || pScriptNode->GetClassID() != XFA_ELEMENT_Script) { + if (!pScriptNode || pScriptNode->GetClassID() != XFA_ELEMENT_Script) return FALSE; - } + CXFA_Node* variablesNode = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent); - if (!variablesNode || variablesNode->GetClassID() != XFA_ELEMENT_Variables) { + if (!variablesNode || variablesNode->GetClassID() != XFA_ELEMENT_Variables) return FALSE; - } - FX_BOOL bRes = FALSE; + void* lpVariables = m_mapVariableToHValue.GetValueAt(pScriptNode); - if (lpVariables) { - FXJSE_HCONTEXT hVariableContext = (FXJSE_HCONTEXT)lpVariables; - FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(hVariableContext); - FXJSE_HVALUE hVariableValue = FXJSE_Value_Create(m_hJsRuntime); - if (!bGetter) { - FXJSE_Value_SetObjectOwnProp(hObject, szPropName, hValue); - bRes = TRUE; - } else if (FXJSE_Value_ObjectHasOwnProp(hObject, szPropName, FALSE)) { - FXJSE_Value_GetObjectProp(hObject, szPropName, hVariableValue); - if (FXJSE_Value_IsFunction(hVariableValue)) { - FXJSE_Value_SetFunctionBind(hValue, hVariableValue, hObject); - } else if (bGetter) { - FXJSE_Value_Set(hValue, hVariableValue); - } else { - FXJSE_Value_Set(hVariableValue, hValue); - } - bRes = TRUE; - } - FXJSE_Value_Release(hVariableValue); - FXJSE_Value_Release(hObject); - } + if (!lpVariables) + return FALSE; + + FX_BOOL bRes = FALSE; + FXJSE_HCONTEXT hVariableContext = (FXJSE_HCONTEXT)lpVariables; + FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(hVariableContext); + FXJSE_HVALUE hVariableValue = FXJSE_Value_Create(m_hJsRuntime); + if (!bGetter) { + FXJSE_Value_SetObjectOwnProp(hObject, szPropName, hValue); + bRes = TRUE; + } else if (FXJSE_Value_ObjectHasOwnProp(hObject, szPropName, FALSE)) { + FXJSE_Value_GetObjectProp(hObject, szPropName, hVariableValue); + if (FXJSE_Value_IsFunction(hVariableValue)) + FXJSE_Value_SetFunctionBind(hValue, hVariableValue, hObject); + else if (bGetter) + FXJSE_Value_Set(hValue, hVariableValue); + else + FXJSE_Value_Set(hVariableValue, hValue); + bRes = TRUE; + } + FXJSE_Value_Release(hVariableValue); + FXJSE_Value_Release(hObject); return bRes; } + void CXFA_ScriptContext::ReleaseVariablesMap() { FX_POSITION ps = m_mapVariableToHValue.GetStartPosition(); while (ps) { CXFA_Object* pScriptNode; - FXJSE_HCONTEXT hVariableContext; + FXJSE_HCONTEXT hVariableContext = nullptr; m_mapVariableToHValue.GetNextAssoc(ps, pScriptNode, hVariableContext); FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(hVariableContext); - CXFA_Object* lpCurNode = (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); - if (lpCurNode) { - delete (CXFA_ThisProxy*)lpCurNode; - lpCurNode = NULL; - } + delete static_cast(FXJSE_Value_ToObject(hObject, nullptr)); FXJSE_Value_Release(hObject); FXJSE_Context_Release(hVariableContext); - hVariableContext = NULL; } m_mapVariableToHValue.RemoveAll(); } + void CXFA_ScriptContext::DefineJsClass() { m_JsNormalClass.constructor = NULL; m_JsNormalClass.name = "XFAObject"; diff --git a/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp b/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp index 6ea1a331c1..fa21a50b3e 100644 --- a/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp +++ b/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp @@ -19,15 +19,12 @@ #include "xfa/fxfa/parser/xfa_utils.h" CXFA_ResolveProcessor::CXFA_ResolveProcessor(void) - : m_pNodeHelper(NULL), m_iCurStart(0) { - m_pNodeHelper = new CXFA_NodeHelper; -} + : m_pNodeHelper(new CXFA_NodeHelper), m_iCurStart(0) {} + CXFA_ResolveProcessor::~CXFA_ResolveProcessor(void) { - if (m_pNodeHelper) { - delete m_pNodeHelper; - m_pNodeHelper = NULL; - } + delete m_pNodeHelper; } + int32_t CXFA_ResolveProcessor::XFA_ResolveNodes(CXFA_ResolveNodesData& rnd) { if (rnd.m_CurNode == NULL) { return -1; diff --git a/xfa/fxgraphics/cagg_graphics.cpp b/xfa/fxgraphics/cagg_graphics.cpp index 4c9e41fea3..a4211810c4 100644 --- a/xfa/fxgraphics/cagg_graphics.cpp +++ b/xfa/fxgraphics/cagg_graphics.cpp @@ -26,7 +26,5 @@ FX_ERR CAGG_Graphics::Create(CFX_Graphics* owner, } CAGG_Graphics::~CAGG_Graphics() { - if (m_owner->m_renderDevice) - delete (CFX_FxgeDevice*)m_owner->m_renderDevice; - m_owner = nullptr; + delete m_owner->m_renderDevice; } diff --git a/xfa/fxgraphics/cfx_path_generator.cpp b/xfa/fxgraphics/cfx_path_generator.cpp index ace3da154f..984e2e9d1a 100644 --- a/xfa/fxgraphics/cfx_path_generator.cpp +++ b/xfa/fxgraphics/cfx_path_generator.cpp @@ -6,18 +6,16 @@ #include "xfa/fxgraphics/cfx_path_generator.h" -CFX_PathGenerator::CFX_PathGenerator() { - m_pPathData = NULL; -} +CFX_PathGenerator::CFX_PathGenerator() : m_pPathData(nullptr) {} + void CFX_PathGenerator::Create() { m_pPathData = new CFX_PathData; } + CFX_PathGenerator::~CFX_PathGenerator() { - if (m_pPathData) { - delete m_pPathData; - m_pPathData = NULL; - } + delete m_pPathData; } + void CFX_PathGenerator::AddPathData(CFX_PathData* pPathData) { if (pPathData && pPathData->GetPointCount() > 0) { int nCount = pPathData->GetPointCount(); diff --git a/xfa/fxjse/context.cpp b/xfa/fxjse/context.cpp index abb30c5dc5..9a6b9120a2 100644 --- a/xfa/fxjse/context.cpp +++ b/xfa/fxjse/context.cpp @@ -11,6 +11,14 @@ #include "xfa/fxjse/util_inline.h" #include "xfa/fxjse/value.h" +namespace { + +CFXJSE_Context* CFXContextFromHContext(FXJSE_HCONTEXT hContext) { + return reinterpret_cast(hContext); +} + +} // namespace + FXJSE_HCONTEXT FXJSE_Context_Create(FXJSE_HRUNTIME hRuntime, const FXJSE_CLASS* lpGlobalClass, void* lpGlobalObject) { @@ -20,17 +28,14 @@ FXJSE_HCONTEXT FXJSE_Context_Create(FXJSE_HRUNTIME hRuntime, } void FXJSE_Context_Release(FXJSE_HCONTEXT hContext) { - CFXJSE_Context* pContext = reinterpret_cast(hContext); - if (pContext) { - delete pContext; - } + delete CFXContextFromHContext(hContext); } FXJSE_HVALUE FXJSE_Context_GetGlobalObject(FXJSE_HCONTEXT hContext) { - CFXJSE_Context* pContext = reinterpret_cast(hContext); - if (!pContext) { - return NULL; - } + CFXJSE_Context* pContext = CFXContextFromHContext(hContext); + if (!pContext) + return nullptr; + CFXJSE_Value* lpValue = CFXJSE_Value::Create(pContext->GetRuntime()); ASSERT(lpValue); pContext->GetGlobalObject(lpValue); @@ -76,8 +81,7 @@ FX_BOOL FXJSE_ExecuteScript(FXJSE_HCONTEXT hContext, const FX_CHAR* szScript, FXJSE_HVALUE hRetValue, FXJSE_HVALUE hNewThisObject) { - CFXJSE_Context* pContext = reinterpret_cast(hContext); - ASSERT(pContext); + CFXJSE_Context* pContext = CFXContextFromHContext(hContext); return pContext->ExecuteScript( szScript, reinterpret_cast(hRetValue), reinterpret_cast(hNewThisObject)); @@ -152,12 +156,8 @@ CFXJSE_Context* CFXJSE_Context::Create(v8::Isolate* pIsolate, } CFXJSE_Context::~CFXJSE_Context() { - for (int32_t i = 0, count = m_rgClasses.GetSize(); i < count; i++) { - CFXJSE_Class* pClass = m_rgClasses[i]; - if (pClass) { - delete pClass; - } - } + for (int32_t i = 0, count = m_rgClasses.GetSize(); i < count; i++) + delete m_rgClasses[i]; m_rgClasses.RemoveAll(); } -- cgit v1.2.3