cwUi.cpp : check for null ele_t.eleName wherever eleName is accessed.

This commit is contained in:
kevin.larke 2020-04-23 13:53:30 -04:00
parent ffe367ed38
commit 9288040004

View File

@ -123,7 +123,7 @@ namespace cw
appIdMapRecd_t* m = mem::allocZ<appIdMapRecd_t>(); appIdMapRecd_t* m = mem::allocZ<appIdMapRecd_t>();
m->parentAppId = parentAppId; m->parentAppId = parentAppId;
m->appId = appId; m->appId = appId;
m->eleName = mem::duplStr(eleName); m->eleName = eleName==nullptr ? nullptr : mem::duplStr(eleName);
m->link = p->appIdMap; m->link = p->appIdMap;
p->appIdMap = m; p->appIdMap = m;
@ -136,7 +136,7 @@ namespace cw
e->parent = parent; e->parent = parent;
e->uuId = p->eleN; e->uuId = p->eleN;
e->appId = appId; e->appId = appId;
e->eleName = mem::duplStr(eleName); e->eleName = eleName==nullptr ? nullptr : mem::duplStr(eleName);
if( p->eleN == p->eleAllocN ) if( p->eleN == p->eleAllocN )
{ {
@ -211,7 +211,7 @@ namespace cw
unsigned _findElementUuId( ui_t* p, const char* eleName ) unsigned _findElementUuId( ui_t* p, const char* eleName )
{ {
for(unsigned i=0; i<p->eleN; ++i) for(unsigned i=0; i<p->eleN; ++i)
if( strcmp(p->eleA[i]->eleName,eleName) == 0 ) if( textCompare(p->eleA[i]->eleName,eleName) == 0 )
return p->eleA[i]->uuId; return p->eleA[i]->uuId;
return kInvalidId; return kInvalidId;
@ -298,7 +298,7 @@ namespace cw
// form the create json message string // form the create json message string
//unsigned i = snprintf( p->buf, p->bufN, "{ \"op\":\"create\", \"parent\":\"%s\", \"children\":{ \"%s\":{ \"eleName\":\"%s\", \"appId\":%i, \"uuId\":%i, \"class\":\"%s\", \"title\":\"%s\" ", parentEleName, eleTypeStr, eleName, appId, newEle->uuId, clas, title ); //unsigned i = snprintf( p->buf, p->bufN, "{ \"op\":\"create\", \"parent\":\"%s\", \"children\":{ \"%s\":{ \"eleName\":\"%s\", \"appId\":%i, \"uuId\":%i, \"class\":\"%s\", \"title\":\"%s\" ", parentEleName, eleTypeStr, eleName, appId, newEle->uuId, clas, title );
unsigned i = snprintf( p->buf, p->bufN, "{ \"op\":\"create\", \"parentUuId\":\"%i\", \"type\":\"%s\", \"eleName\":\"%s\", \"appId\":\"%i\", \"uuId\":%i, \"className\":\"%s\", \"title\":\"%s\" ", parentEle->uuId, eleTypeStr, eleName, appId, newEle->uuId, clas, title ); unsigned i = snprintf( p->buf, p->bufN, "{ \"op\":\"create\", \"parentUuId\":\"%i\", \"type\":\"%s\", \"eleName\":\"%s\", \"appId\":\"%i\", \"uuId\":%i, \"className\":\"%s\", \"title\":\"%s\" ", parentEle->uuId, eleTypeStr, eleName==nullptr ? "" : eleName, appId, newEle->uuId, clas, title );
// add the UI specific attributes // add the UI specific attributes
@ -737,7 +737,9 @@ unsigned cw::ui::findElementUuId( handle_t h, unsigned parentUuId, unsigned appI
ui_t* p = _handleToPtr(h); ui_t* p = _handleToPtr(h);
for(unsigned i=0; i<p->eleN; ++i) for(unsigned i=0; i<p->eleN; ++i)
if( p->eleA[i]->parent->uuId==parentUuId && p->eleA[i]->appId == appId ) if(((p->eleA[i]->parent==nullptr && parentUuId==kRootUuId) ||
(p->eleA[i]->parent!=nullptr && p->eleA[i]->parent->uuId==parentUuId))
&& p->eleA[i]->appId == appId )
return p->eleA[i]->uuId; return p->eleA[i]->uuId;
return kInvalidId; return kInvalidId;
} }