From da356d94daa01e41619df2b226fc9f93e1f40888 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 10 Mar 2013 21:22:07 +0100 Subject: [PATCH] CComponentsHeader/Icon: use inherited destructor Inherited destructor contains identic code. --- src/gui/components/cc.h | 7 ++++--- src/gui/components/cc_frm.cpp | 5 +++++ src/gui/components/cc_frm_header.cpp | 11 +---------- src/gui/components/cc_frm_window.cpp | 13 +++++++------ 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/gui/components/cc.h b/src/gui/components/cc.h index 0d529f725..6bc834ed9 100644 --- a/src/gui/components/cc.h +++ b/src/gui/components/cc.h @@ -394,6 +394,7 @@ class CComponentsForm : public CComponentsItem virtual int getCCItemId(CComponentsItem* cc_Item); virtual CComponentsItem* getCCItem(const uint& cc_item_id); virtual void paintCCItems(); + virtual void cleanCCForm(); }; class CComponentsIconForm : public CComponentsForm @@ -410,6 +411,7 @@ class CComponentsIconForm : public CComponentsForm CComponentsIconForm(); CComponentsIconForm(const int x_pos, const int y_pos, const int w, const int h, const std::vector v_icon_names, bool has_shadow = CC_SHADOW_OFF, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); +// ~CComponentsIconForm(); //inherited from CComponentsForm void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); void initCCIcons(); @@ -479,8 +481,7 @@ class CComponentsHeader : public CComponentsForm fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); CComponentsHeader(const int x_pos, const int y_pos, const int w, const int h = 0, neutrino_locale_t caption_locale = NONEXISTANT_LOCALE, const char* icon_name = NULL, const int buttons = 0,bool has_shadow = CC_SHADOW_OFF, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); - -// ~CComponentsHeader(); +// ~CComponentsHeader(); //inherited from CComponentsForm void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); void setHeaderText(const std::string& caption); @@ -512,7 +513,7 @@ class CComponentsWindow : public CComponentsForm CC_WINDOW_ITEM_HEADER = 0 }; CComponentsWindow(); - ~CComponentsWindow(); + ~CComponentsWindow(); void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); void setWindowCaption(const std::string& text){ccw_caption = text;}; diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index 728fc40bb..e49772a52 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -61,6 +61,11 @@ CComponentsForm::CComponentsForm(const int x_pos, const int y_pos, const int w, } CComponentsForm::~CComponentsForm() +{ + cleanCCForm(); +} + +void CComponentsForm::cleanCCForm() { #ifdef DEBUG_CC printf("[CComponents] calling %s...\n", __FUNCTION__); diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp index a67aac746..41417d1d0 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -86,16 +86,7 @@ CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const in initCCHItems(); } -#if 0 -CComponentsHeader::~CComponentsHeader() -{ - hide(); - clearSavedScreen(); - clearCCItems(); - clear(); -} -#endif - + void CComponentsHeader::initVarHeader() { //CComponentsHeader diff --git a/src/gui/components/cc_frm_window.cpp b/src/gui/components/cc_frm_window.cpp index fa2c22634..1ed996f6d 100644 --- a/src/gui/components/cc_frm_window.cpp +++ b/src/gui/components/cc_frm_window.cpp @@ -42,6 +42,13 @@ CComponentsWindow::CComponentsWindow() initVarWindow(); } +CComponentsWindow::~CComponentsWindow() +{ + if (ccw_head) + delete ccw_head; + cleanCCForm(); +} + void CComponentsWindow::initVarWindow() { //CComponentsForm @@ -61,12 +68,6 @@ void CComponentsWindow::initVarWindow() setShadowOnOff(true); } -CComponentsWindow::~CComponentsWindow() -{ - if (ccw_head) - delete ccw_head; -} - void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text) { ccw_caption = g_Locale->getText(locale_text);