Access violation in AdvScrollControl

I seem to be starting to get an access violation in the AdvScrollControl finalization code when closing my app using this sequence:

1. Switch from Windows VCL Style to another VCL style
2. Switch back to the default Windows VCL Style
3. Close the app.

This is easily reproducible 100% of the time with my app and it appears that for my preliminary tests that as long as I have not shown any TMS controls that uses your AdvScrollControl component, I do not get this access violation when closing the app, so thought I'd run it by you.  I will try to get you a sample app.

Access violation is:

First chance exception at S0040A552. Exception class SC0DDDDD5 with message 'access violation at 0x0040a552: read of address 0x00000800'. Process myapp.exe (29596)

Here is the call stack trace during the app close:

System.TObject.lnheritsFrom(???)
System JsClass(SE5D0E90,TCIass(Sl95505C))
Vcl.Styles.TStyleEngine.DoUnregisterStyleHook(TCIass(S195505C),TStyleHookClass(S19S4F0C))
Vcl.Styles.TStyleEngine.Notification(???,???)
Vcl.Themes.TCustomStyleEngine.UnRegisterStyleHook(???,???)
AdvScrollControl.Finalization System.FinalizeUnits System._HaltO 0040bea1 @HaltO + SB1
752c6359 KERNEL32.BaseThreadlnitThunk + 0x19 776a7b74 ntdll.RtlGetAppContainerNamedObjectPath + 0xe4 776a7b44 ntdll.RtlGetAppContainerNamedObjectPath + 0xb4

Didn't notice that SnagIt ran some lines together... here is the proper line break of the call stack:

System.TObject.lnheritsFrom(???)
System JsClass(SE5D0E90,TCIass(Sl95505C))
Vcl.Styles.TStyleEngine.DoUnregisterStyleHook(TCIass(S195505C),TStyleHookClass(S19S4F0C))
Vcl.Styles.TStyleEngine.Notification(???,???)
Vcl.Themes.TCustomStyleEngine.UnRegisterStyleHook(???,???)
AdvScrollControl.Finalization
System.FinalizeUnits
System._HaltO
0040bea1 @HaltO + SB1
752c6359 KERNEL32.BaseThreadlnitThunk + 0x19
776a7b74 ntdll.RtlGetAppContainerNamedObjectPath + 0xe4
776a7b44 ntdll.RtlGetAppContainerNamedObjectPath + 0xb4

One thing to note is that you have to run it in the IDE in debug mode.  If run outside of the IDE or not in debug mode, you do not get the access violation, however, the task never dies and you have to use the Task Manager to kill it.

I tested this here with a TAdvRichEditor on the form (descends from TAdvScrollControl) and used code to switch styles:


procedure TForm3.Button1Click(Sender: TObject);
begin
    TStyleManager.TrySetStyle('Windows');
end;

procedure TForm3.Button2Click(Sender: TObject);
begin
    TStyleManager.TrySetStyle('Carbon');
end;

and I cannot reproduce an issue.

I am also having trouble creating a sample to illustrate using just the TMS controls I use.  The TMS controls are within other controls, so it might take a while to see what combination causes the issue.  I'll update if I find anything.  Thanks for trying though.