CComponentsForm/Header/Icons/Window: try to fix multiple inits and paints

Some items had multiple inits and some calls of clearCCItems()
have caused segfaults, hope this fix this.


Origin commit data
------------------
Branch: ni/coolstream
Commit: 4a931af6ef
Author: Thilo Graf <dbt@novatux.de>
Date: 2013-03-13 (Wed, 13 Mar 2013)



------------------
This commit was generated by Migit
This commit is contained in:
2013-03-13 23:23:19 +01:00
parent bfda4b1d37
commit f918ed8e2a
5 changed files with 164 additions and 111 deletions

View File

@@ -44,8 +44,9 @@ CComponentsWindow::CComponentsWindow()
CComponentsWindow::~CComponentsWindow()
{
if (ccw_head)
delete ccw_head;
#ifdef DEBUG_CC
printf("[~CComponentsWindow] [%s - %d] delete...\n", __FUNCTION__, __LINE__);
#endif
cleanCCForm();
}
@@ -75,25 +76,29 @@ void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text)
void CComponentsWindow::initHeader()
{
if (ccw_head){
delete ccw_head;
ccw_head = NULL;
}
ccw_head = new CComponentsHeader();
if (ccw_head == NULL){
ccw_head = new CComponentsHeader();
initHeader();
//add header item only one time
addCCItem(ccw_head);
}
ccw_head->setXPos(0);
ccw_head->setYPos(0);
ccw_head->setWidth(width);
ccw_head->setHeaderIcon(ccw_icon_name);
ccw_head->setHeaderText(ccw_caption);
//set header properties
if (ccw_head){
ccw_head->setXPos(0);
ccw_head->setYPos(0);
ccw_head->setWidth(width);
ccw_head->setHeaderIcon(ccw_icon_name);
ccw_head->setHeaderText(ccw_caption);
}
}
void CComponentsWindow::initCCWItems()
{
#ifdef DEBUG_CC
printf("[CComponentsWindow] [%s - %d] init items...\n", __FUNCTION__, __LINE__);
#endif
initHeader();
if (ccw_head)
addCCItem(ccw_head);
}
void CComponentsWindow::paint(bool do_save_bg)
@@ -101,9 +106,6 @@ void CComponentsWindow::paint(bool do_save_bg)
//prepare items before paint
initCCWItems();
//paint body
paintInit(do_save_bg);
//paint
paintCCItems();
//paint form contents
paintForm(do_save_bg);
}