hi
i am using powerbuilder 8 version. suddenly my application gets closed in a particular screen in which whenever i click ok button.In ok button it calls the function updaterightstree(root); in that line app gets closed.Its an existing screen only.but dont know why the issue occurred suddenly
root=tv_userrights.finditem(RootTreeitem!,0);
updaterightstree(root);
updaterightstree(root) has below lines:
int h_child;
char flag;
String ls_windowname
h_child=tv_userrights.finditem( childtreeitem!,h_root)
if h_child=-1 then
return
else
do while h_child <> -1
treeviewitem tvi;
tv_userrights.getitem( h_child,tvi);
if tvi.statepictureindex=1 then
flag='N';
else
flag='Y';
end if
insert into ENT_RIGHTS(USERS,WINDOWNAME,RIGHTS)
select :sle_userid.text,windowname,:flag from ent_menuitems where description=:tvi.label;
if sqlca.sqlcode = -1 then
messagebox('Alert !..',sqlca.sqlerrtext)
end if
updateRightsTree(h_child);
h_child=tv_userrights.finditem(nexttreeitem!,h_child)
loop
end if
can anyone please help regarding this???
Regards
Backya
i dont get you.. What is GPF? Where i need to use isvalid() command? can you pls explain
Regards
Backya
You should probably use IsValid(tvi) or check the return code after tv_userrights.getitem( h_child,tvi); I would expect that the GetItem would work when given a valid handle, and you are properly checking h_child, but it is a good programming practice to check these sorts of things and be able to eliminate them from consideration as causing unexpected crashes.
You should probably be checking the return value after root=tv_userrights.finditem(RootTreeitem!,0); to verify that the FindItem actually found something. Again, I would expect that h_child=tv_userrights.finditem( childtreeitem!,h_root) would return a -1 if the h_root sent to it was -1, but verifying ahead of time is good practice and would eliminate that as a possible source of the program crash.