Another Bug?
vining
Posts: 4,368
In the following code I create a stack var structure to clear my global working structure before the next go around. It's not really necessary since I'm writing new values to every element but for some reason I added it. When this code runs the structure clears and then I populate the values but when a function called directly after runs it receives a UI_Indx of 0 from this code block and that value of UI_indx coming into this code is definitely set.
The section of code:
My diagnostic printout:
If I take out this line:
Again I don't need this and it's probably left over from when I was only updating a couple of values here, not everything but it should still work regardless of the fact that I don't need it. Fortunately I don't so it's an easy fix but why?
Take out this:
This had me stumped for a long time since this shouldn't be a problem. Anybody seen similar anomalies?
Master is running v4.1.373
The section of code:
DEFINE_FUNCTION fnFavIcon_SetResource(INTEGER iUI_Indx,INTEGER iUser,INTEGER iFav,CHAR iProtocol_Path[]) { if(sFavIcon.nInitializing != FAVICON_INIT_EXIT) { STACK_VAR _sSent sClearSent; fnFavIcon_DeBug("'fnFavIcon_SetResource(), UI-[ ', itoa(iUI_Indx),' ], USER-[ ',itoa(iUser),' ], FAV-[ ',itoa(iFav),' ], INIT STATE-[ ',itoa(sFavIcon.nInitializing),' ] :DEBUG<',ITOA(__LINE__),'>'"); if(sFavIcon.nInitializing != FAVICON_INIT_RUN) { sFavIcon.nInitializing = FAVICON_INIT_RUN; fnFavIcon_FB_INIT(iUI_Indx); } sFavIcon.sSentUI = sClearSent; sFavIcon.sSentUI.cResource = "'FavIcon U',itoa(iUser),' F',itoa(iFav)"; sFavIcon.sSentUI.nUI_Indx = iUI_Indx; sFavIcon.sSentUI.nUser = iUser; sFavIcon.sSentUI.nFav = iFav; sFavIcon.sSentUI.nChnlIndx = sFavIcon.sUser[iUser].nCableChnlIndx[iFav]; sFavIcon.sSentUI.nChnl = sCableChnl[sFavIcon.sSentUI.nChnlIndx].nChnl; sFavIcon.sUser[iUser].cResource[iFav] = sFavIcon.sSentUI.cResource; if(find_string(sCableChnl[sFavIcon.sSentUI.nChnlIndx].cIcon,"'.png'",1) || find_string(sCableChnl[sFavIcon.sSentUI.nChnlIndx].cIcon,"'.jpg'",1)) { fnFavIcon_DoSend_UI_CMD(iUI_Indx,"'^RAF-',sFavIcon.sSentUI.cResource,iProtocol_Path,sCableChnl[sFavIcon.sUser[iUser].nCableChnlIndx[iFav]].cIcon,'%R0'"); fnFavIcon_DoSend_UI_CMD(iUI_Indx,"'^RFRP-',sFavIcon.sSentUI.cResource,',once'"); } else { fnFavIcon_DeBug("'fnFavIcon_SetResource(), UI-[ ', itoa(iUI_Indx),' ], USER-[ ',itoa(iUser),' ], FAV-[ ',itoa(iFav),' ], ERROR SUPPORTED FILE TYPE FOUND! :DEBUG<',ITOA(__LINE__),'>'"); fnFavIcon_DeBug("'fnFavIcon_SetResource(), ERROR ### UI-[ ',itoa(sFavIcon.sSentUI.nUI_Indx),' ], CHECK RESOURCE ICON-[ ',sCableChnl[sFavIcon.sSentUI.nChnlIndx].cIcon,' ] ### :DEBUG<',ITOA(__LINE__),'>'"); fnFavIcon_DeBug("'fnFavIcon_SetResource(), ERROR ### UI-[ ',itoa(sFavIcon.sSentUI.nUI_Indx),' ], CHECK RESOURCE CABLE CHNL-[ ',itoa(sCableChnl[sFavIcon.sSentUI.nChnlIndx].nChnl),' ] ### :DEBUG<',ITOA(__LINE__),'>'"); fnFavIcon_Init_UIs(sFavIcon.sSentUI.nUI_Indx,sFavIcon.sSentUI.cResource);//continue to th next }
My diagnostic printout:
Line 358 (19:41:48):: FAVICON-[ * ] DEBUG:[ L1 ], fnFavIcon_Init_UIs(), UI-[ 3 ], USER-[ 4 ], FAV-[ 6 ], RCV'D RESOURCE-[ FavIcon U4 F6 ] :DEBUG<740> Line 359 (19:41:48):: FAVICON-[ * ] DEBUG:[ L1 ], fnFavIcon_SetResource(), UI-[ 3 ], USER-[ 4 ], FAV-[ 5 ], INIT STATE-[ 2 ] :DEBUG<950> Line 360 (19:41:48):: FAVICON-[ * ] DEBUG:[ L1 ], fnFB_DoSend_UI_CMD(), UI-[ 0 ], Cmd-[ ^RAF-FavIcon U4 F5,%P1%Uxxxxxxxx%Syyyyyyyyyy%H192.168.1.60%Aimages/tv_icons%Fabc_hd.png%R0 ] :DEBUG<418> Line 361 (19:41:48):: FAVICON-[ * ] DEBUG:[ L1 ], fnFB_DoSend_UI_CMD(), UI-[ 0 ], Cmd-[ ^RFRP-FavIcon U4 F5,once ] :DEBUG<418>From this you can see the function fnFavIcon_SetResource() receives a UI_Indx value of 3 but then passes a value of 0 to fnFavIcon_DoSend_UI_CMD().
If I take out this line:
sFavIcon.sSentUI = sClearSent;everything works fine. They are both structure type _sSent so sClearSent should clear sFavIcon.sSentUI with no problems and it does but for some odd reason populating sFavIcon.sSentUI.nUI_Indx = iUI_Indx directly after the value doesn't stick and by the micro second it takes to call and pass that value to the next function the value is gone or was simply never written.
Again I don't need this and it's probably left over from when I was only updating a couple of values here, not everything but it should still work regardless of the fact that I don't need it. Fortunately I don't so it's an easy fix but why?
Take out this:
STACK_VAR _sSent sClearSent; sFavIcon.sSentUI = sClearSent;and everything works but leave it in and the iUI_Indx value passed to the subsequent functions is 0 when a value other than 0 comes in.
This had me stumped for a long time since this shouldn't be a problem. Anybody seen similar anomalies?
Master is running v4.1.373
0
Comments
Paul
And while there's definitely an issue I don't see how the processor handling nested structures slowly could be the issue. Since the processor is single threaded it has to finish updating that branch of the structure before continuing to following code that re-populates it value. And the weird thing is it only seemed to affect the UI_Indx var and not the others that were also updated there after. I think I might have to step through the code to see if I can get a better indication of where this breaks.