TTabSheet.TabVisible := True on activePage prevents new page from drawing
Original Reporter info from Mantis: djenkins @dfjenkins
-
Reporter name: David Jenkins
Original Reporter info from Mantis: djenkins @dfjenkins
- Reporter name: David Jenkins
Description:
With two tabs on pagecontrol (tab1, tab2) if tab1.TabVisible set is set false, the lcl layer will request that the tab1 handle be destroyed and then set activepage to next tab (tab2). Currently on Cocoa when this is requested tab1 goes away, tab2 is select, but the contents of tab2 are not draw.
Steps to reproduce:
Run attached project. Select tab1. Click button that toggles TabVisible of tab1. Tab1 will go away and tab2 will be selected but contents of tab2 will not draw.
Additional information:
Problem is associated with syncing between LCL layer and Cocoa layer of active page index. LCL layer, as part of tab1.handle removal, requests that Cocoa layer change active page by way of TCocoaWSCustomTabControl.SetPageIndex. Changing the TCocoaTabControl index triggers a call to procedure TCocoaTabControl.tabView_willSelectTabViewItem which will send a message down to LCL with new PageIndex. SetPageIndex is meant to sync Cocoa layer will changes in LCL layer. tabView_willSelectTabViewItem is meant to alert LCL layer to user changes in Cocoa Layer. There is not need for them to loop around i.e. Change to Cocoa driven by LCL request don't need to be run back down to LCL layer no more than LCL layer needs to let Cocoa layer now of LCL changes requested by tabView_willSelectTabViewItem.
This loop, in most cases, is not a problem. In this case it is as it happens at the same time that the number of tabs is being changed and thus the mapping between PageIndex and total number of tabs. The code called by tabView_willSelectTabViewItem will try to translate the Cocoa PageIndex value into the appropriate LCL Index (by way of TTabControl.TabToPageIndex) Because the number of pages are changing this value is set for the number of tabs before removal and then when TcustomPage.WMPaint is called it is post removal and now PageIndex > PageCount and WMPaint exits.
Patch is attached that follows what Carbon does in TCarbonTabsControl.UpdateTabIndex and sets a 'ignoreChange flag that when true tells TCocoaTabControl.tabView_willSelectTabViewItem to not report to LCL layer.
Mantis conversion info:
- Mantis ID: 35172
- OS: macOS
- OS Build: all
- Platform: Cocoa
- Version: 2.0
- Fixed in revision: 61009 (#aecd8403)