cc_frm.cpp: Leave method 'getCCItem()' if item collection is empty.

It makes no sense to execute these method if no items are existing and
avoids unintended debug error output with "out of range" content.


Origin commit data
------------------
Commit: ddc3051fef
Author: Thilo Graf <dbt@novatux.de>
Date: 2020-01-18 (Sat, 18 Jan 2020)
This commit is contained in:
2020-01-18 00:10:20 +01:00
committed by vanhofen
parent 78193bdceb
commit fc52b1312e

View File

@@ -262,6 +262,9 @@ int CComponentsForm::genIndex()
CComponentsItem* CComponentsForm::getCCItem(const uint& cc_item_id) const CComponentsItem* CComponentsForm::getCCItem(const uint& cc_item_id) const
{ {
if (v_cc_items.empty())
return NULL;
if (cc_item_id >= size()){ if (cc_item_id >= size()){
dprintf(DEBUG_NORMAL, "[CComponentsForm] [%s - %d] Error: inside container type = [%d] [%s] parameter cc_item_id = %u, out of range (size = %zx)...\n", __func__, __LINE__, cc_item_type.id, cc_item_type.name.c_str(), cc_item_id, size()); dprintf(DEBUG_NORMAL, "[CComponentsForm] [%s - %d] Error: inside container type = [%d] [%s] parameter cc_item_id = %u, out of range (size = %zx)...\n", __func__, __LINE__, cc_item_type.id, cc_item_type.name.c_str(), cc_item_id, size());
return NULL; return NULL;
@@ -269,6 +272,7 @@ CComponentsItem* CComponentsForm::getCCItem(const uint& cc_item_id) const
if (v_cc_items.at(cc_item_id)) if (v_cc_items.at(cc_item_id))
return v_cc_items.at(cc_item_id); return v_cc_items.at(cc_item_id);
return NULL; return NULL;
} }