Hi,
We encountered a problem when adding an extra page at runtime to a TTMSFMXPageControl.
The program stayed in an eternal loop and never came back.
The program stayed in an eternal loop and never came back.
I took us a long time to be able to reproduce the issue, because some user were experiencing the problem while others not.
Eventually we found out that screen resolution/size was a factor, which gave us a direction to look at.
Eventually we found out that screen resolution/size was a factor, which gave us a direction to look at.
We traced the problem down to the method TTMSFMXCustomTabSet.ScrollToTab.
Unfortunately I don't have a small test program to reproduce the error.
What do we do?
* The pagecontrol has tabwidth set to autosize
* We are using long texts in the tabs
* Create a new page at runtime
* Set the new page active by using ActivePage := myNewPage
It then ends up in TTMSFMXCustomTabSet.HandleChangeTab before it goes to TTMSFMXCustomTabSet.ScrollToTab.
The code below causes the loop to never end.
(it seems strange that the variables in the condition aren't changed within the loop directly).
(it seems strange that the variables in the condition aren't changed within the loop directly).
procedure TTMSFMXCustomTabSet.ScrollToTab(ATabIndex: Integer);
begin
...
if ATabIndex > FLastTabIndex then
begin
while FLastTabIndex < ATabIndex do
begin
Inc(FStartTab);
if not IsTabVisible(FStartTab) then
FStartTab := GetNextTab(FStartTab);
UpdateTabs(False, True);
end;
end
...
end;
We think that the problem occurs when a (new) tab just ends on the same pixel as the width of the entire pagecontrol.
This made it hard to reproduce and trace.
The loop keeps setting the FStartTab back and forth then.
Hope you can make anything of my explanation.
Thx
John