Win32lib tweak

new topic     » topic index » view thread      » older message » newer message

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.

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu