Historical forum-msg-id-136060-edit, Revision 1

Original date:2021-04-07 10:11:07 Edited by: Graeme Subject: Win32lib tweak

Hi EU people :) Apologies, not really sure who is maintaining win32lib or where I should be posting this but...

Not a big issue but I think the setTCVisible() procedure needs a slight tweak


procedure setTCVisible(integer TC_id,integer flag)
integer tab_id

if ctrl_Type[TC_id] = TabControl then
tab_id = getTabItem(TC_id)
end if
call_proc(r_setControlVisible,{ctrl_Group[tab_id],flag})
end procedure


I'm unsure why the call_proc() would be outside of the if ctrl_Type[TC_id] = TabControl block as it uses tab_id for a parameter which would be unassigned if the test failed. It's also worth pointing out that this error has never occurred because test is itself redundant anyway as the only 2 source lines that call the procedure do it as a result of this same check so it will never fail.

getTabItem() returns 0 if there is no currently selected tab item in the control, so it is quite possible to get an OOB subscript crash just by creating a tab control and calling setVisible() on it.

I would suggest the following:

procedure setTCVisible(integer TC_id,integer flag)
integer tab_id

tab_id = getTabItem(TC_id)
if tab_id then
call_proc(r_setControlVisible,{ctrl_Group[tab_id],flag})\ end if
end procedure


Arguably there is no real need to call setVisible() on a tab control before it has an active tab item, but I don't think the lib should be crashing with an OOB subscript just because of that and it's cleaner code anyway.

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu