Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: xfa/fwl/theme/cfwl_checkboxtp.cpp

Issue 1925363002: Do not check pointers before deleting them. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fwl/theme/cfwl_checkboxtp.h" 7 #include "xfa/fwl/theme/cfwl_checkboxtp.h"
8 8
9 #include "xfa/fde/tto/fde_textout.h" 9 #include "xfa/fde/tto/fde_textout.h"
10 #include "xfa/fwl/basewidget/ifwl_checkbox.h" 10 #include "xfa/fwl/basewidget/ifwl_checkbox.h"
11 #include "xfa/fwl/core/cfwl_themebackground.h" 11 #include "xfa/fwl/core/cfwl_themebackground.h"
12 #include "xfa/fwl/core/cfwl_themetext.h" 12 #include "xfa/fwl/core/cfwl_themetext.h"
13 #include "xfa/fwl/core/ifwl_widget.h" 13 #include "xfa/fwl/core/ifwl_widget.h"
14 #include "xfa/fxgraphics/cfx_color.h" 14 #include "xfa/fxgraphics/cfx_color.h"
15 #include "xfa/fxgraphics/cfx_path.h" 15 #include "xfa/fxgraphics/cfx_path.h"
16 16
17 #define CHECKBOX_SIZE_SIGNMARGIN 3 17 #define CHECKBOX_SIZE_SIGNMARGIN 3
18 #define CHECKBOX_SIZE_SIGNBORDER 2 18 #define CHECKBOX_SIZE_SIGNBORDER 2
19 #define CHECKBOX_SIZE_SIGNPATH 100 19 #define CHECKBOX_SIZE_SIGNPATH 100
20 #define CHECKBOX_COLOR_BOXLT1 (ArgbEncode(255, 172, 168, 153)) 20 #define CHECKBOX_COLOR_BOXLT1 (ArgbEncode(255, 172, 168, 153))
21 #define CHECKBOX_COLOR_BOXLT2 (ArgbEncode(255, 113, 111, 100)) 21 #define CHECKBOX_COLOR_BOXLT2 (ArgbEncode(255, 113, 111, 100))
22 #define CHECKBOX_COLOR_BOXRB1 (ArgbEncode(255, 241, 239, 226)) 22 #define CHECKBOX_COLOR_BOXRB1 (ArgbEncode(255, 241, 239, 226))
23 #define CHECKBOX_COLOR_BOXRB2 (ArgbEncode(255, 255, 255, 255)) 23 #define CHECKBOX_COLOR_BOXRB2 (ArgbEncode(255, 255, 255, 255))
24 24
25 CFWL_CheckBoxTP::CFWL_CheckBoxTP() : m_pCheckPath(NULL) { 25 CFWL_CheckBoxTP::CFWL_CheckBoxTP()
26 m_pThemeData = new CKBThemeData; 26 : m_pThemeData(new CKBThemeData), m_pCheckPath(nullptr) {
27 SetThemeData(0); 27 SetThemeData(0);
28 } 28 }
29
29 CFWL_CheckBoxTP::~CFWL_CheckBoxTP() { 30 CFWL_CheckBoxTP::~CFWL_CheckBoxTP() {
30 if (m_pThemeData) { 31 delete m_pThemeData;
31 delete m_pThemeData;
32 m_pThemeData = NULL;
33 }
34 if (m_pCheckPath) { 32 if (m_pCheckPath) {
35 m_pCheckPath->Clear(); 33 m_pCheckPath->Clear();
36 delete m_pCheckPath; 34 delete m_pCheckPath;
37 m_pCheckPath = NULL; 35 m_pCheckPath = nullptr;
Tom Sepez 2016/04/28 21:47:22 nit: probably not necessary.
Lei Zhang 2016/04/28 22:31:10 Done.
38 } 36 }
39 } 37 }
38
40 FX_BOOL CFWL_CheckBoxTP::IsValidWidget(IFWL_Widget* pWidget) { 39 FX_BOOL CFWL_CheckBoxTP::IsValidWidget(IFWL_Widget* pWidget) {
41 return pWidget && pWidget->GetClassID() == FWL_CLASSHASH_CheckBox; 40 return pWidget && pWidget->GetClassID() == FWL_CLASSHASH_CheckBox;
42 } 41 }
43 uint32_t CFWL_CheckBoxTP::SetThemeID(IFWL_Widget* pWidget, 42 uint32_t CFWL_CheckBoxTP::SetThemeID(IFWL_Widget* pWidget,
44 uint32_t dwThemeID, 43 uint32_t dwThemeID,
45 FX_BOOL bChildren) { 44 FX_BOOL bChildren) {
46 if (m_pThemeData) { 45 if (m_pThemeData) {
47 SetThemeData(FWL_GetThemeColor(dwThemeID)); 46 SetThemeData(FWL_GetThemeColor(dwThemeID));
48 } 47 }
49 return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); 48 return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 pt1.x + px2 * FWLTHEME_BEZIER, 499 pt1.x + px2 * FWLTHEME_BEZIER,
501 pt1.y + py2 * FWLTHEME_BEZIER, pt1.x, pt1.y); 500 pt1.y + py2 * FWLTHEME_BEZIER, pt1.x, pt1.y);
502 FX_FLOAT fScale = fCheckLen / CHECKBOX_SIZE_SIGNPATH; 501 FX_FLOAT fScale = fCheckLen / CHECKBOX_SIZE_SIGNPATH;
503 CFX_Matrix mt; 502 CFX_Matrix mt;
504 mt.Set(1, 0, 0, 1, 0, 0); 503 mt.Set(1, 0, 0, 1, 0, 0);
505 mt.Scale(fScale, fScale); 504 mt.Scale(fScale, fScale);
506 CFX_PathData* pData = m_pCheckPath->GetPathData(); 505 CFX_PathData* pData = m_pCheckPath->GetPathData();
507 pData->Transform(&mt); 506 pData->Transform(&mt);
508 } 507 }
509 } 508 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698