cc_frm; cc_button_select: Avoid possible crash if no item is selectable

Origin commit data
------------------
Commit: 6c511e9ccb
Author: Thilo Graf <dbt@novatux.de>
Date: 2020-12-07 (Mon, 07 Dec 2020)
This commit is contained in:
2020-12-07 23:28:52 +01:00
committed by vanhofen
parent e7fd59b84c
commit 34ab5890c5
2 changed files with 6 additions and 2 deletions

View File

@@ -67,8 +67,10 @@ void CCButtonSelect::setSelectedButton( size_t item_id,
btn->setButtonTextColor(text_col); btn->setButtonTextColor(text_col);
} }
} }
if (!btn) if (!btn){
dprintf(DEBUG_NORMAL, "\033[33m[CCButtonSelect]\t[%s - %d], no button object found...\033[0m\n", __func__, __LINE__); dprintf(DEBUG_NORMAL, "\033[31m[CCButtonSelect]\t[%s - %d], ERROR: btn_container size = %d, no button object available...\033[0m\n", __func__, __LINE__, (int)btn_container->size());
return;
}
fb_pixel_t sel_col = fr_col; fb_pixel_t sel_col = fr_col;
if (btn_container->size() > 1) if (btn_container->size() > 1)

View File

@@ -711,6 +711,8 @@ CComponentsItem* CComponentsForm::getSelectedItemObject() const
CComponentsItem* ret = NULL; CComponentsItem* ret = NULL;
if (sel != -1) if (sel != -1)
ret = static_cast<CComponentsItem*>(this->getCCItem(sel)); ret = static_cast<CComponentsItem*>(this->getCCItem(sel));
else
dprintf(DEBUG_NORMAL, "\033[31m[CComponentsForm]\t[%s - %d], ERROR: no item object found...\033[0m\n", __func__, __LINE__);
return ret; return ret;
} }