I have 32bit Lazarus application (actually CT 5.80) used in iron producing industry running 24/7 on Windows server 2003 R2 SP2, catching all unhandled exceptions. I have this exception being logged from time to time:
EInvalidOperation: TControl.EnableAutoSizing VisualisationForm:TVisualisationForm: missing DisableAutoSizing
All other exceptions are solved and there are no memory leaks left according to heaptrc reports. I would really appreciate If anyone can point me in good direction to fix this, since I am out of ideas.

I have looked at LCL code for
"missing DisableAutoSizing", and found it inside of
"\lcl\include\control.inc":
procedure TControl.EnableAutoSizing
{$IFDEF DebugDisableAutoSizing}(const Reason: string){$ENDIF};
{$IFDEF DebugDisableAutoSizing}
procedure CheckReason;
var
i: Integer;
s: String;
begin
i:=FAutoSizingLockReasons.Count-1;
while i>=0 do begin
if FAutoSizingLockReasons[i]=Reason then begin
FAutoSizingLockReasons.Delete(i);
exit;
end;
dec(i);
end;
s:='TControl.EnableAutoSizing '+DbgSName(Self)+' never disabled with reason "'+Reason+'"';
for i:=0 to FAutoSizingLockReasons.Count-1 do
s+=','+LineEnding+'reason['+IntToStr(i)+']="'+FAutoSizingLockReasons[i]+'"';
RaiseGDBException(s);
end;
{$ENDIF}
begin
{$IFDEF DebugDisableAutoSizing}
CheckReason;
{$ENDIF}
if FAutoSizingLockCount<=0 then
raise EInvalidOperation.Create('TControl.EnableAutoSizing '+DbgSName(Self)+': missing DisableAutoSizing');
dec(FAutoSizingLockCount);
//DebugLn([Space(FAutoSizingLockCount*2),'TControl.EnableAutoSizing ',DbgSName(Self),' ',FAutoSizingLockCount]);
if (FAutoSizingLockCount=0) then
begin
if (Parent<>nil) then
begin
//DebugLn([Space(FAutoSizingLockCount*2),'TControl.EnableAutoSizing ',DbgSName(Self),' enable Parent ',DbgSName(Parent)]);
Parent.EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.DisableAutoSizing'){$ENDIF};
end else
DoAllAutoSize;
end;
end;
It looks suspicious but I might be totally wrong on this since I do not understand it enough to jump into any useful conclusion.
This is how my FormResize looks like (I have attached screenshot to make it more clear):
procedure TVisualisationForm.FormResize(Sender: TObject);
var
i: byte;
begin
try
if CommStatus.Panels.Count > 0 then
for i := 0 to CommStatus.Panels.Count - 1 do
CommStatus.Panels[i].Width := (CommStatus.Width + 2) div CommStatus.Panels.Count;
for i := 0 to 5 do // BF1 leds
BlastFurnacePlcStatus.Panels[i].Width := ((BlastFurnacePlcStatus.Width + 4) div 2) div 6;
for i := 6 to 12 do // BF2 leds
BlastFurnacePlcStatus.Panels[i].Width := ((BlastFurnacePlcStatus.Width + 4) div 2) div 7;
C7Grid.Width := Notebook.ActivePage.Width div 2; // we have to use ActivePage because inactive page width is not refreshed on form resize
BF1Grid.Width := C7Grid.Width;
except
on E: Exception do Logger.SendException('Exception during form resize', E);
end;
end;
Unfrotunately I can not show all of the code and I was not able to isolate this in some small example because application can work even few weeks without exception being logged. I am open for all suggestions.