Access Violation with TCompactWindow.CreateParams on loading form with TAdvToolbarPager

Hi,

I've been hitting random crashes with beta testers of an app that uses the TAdvPager on a secondary form. Now it's finally happening to me on the development machine, so I'm able to debug.

The app was loading perfectly well, and then I added a single TAdvToolbar to a a page of the TAdvToolbarPager - I then added 4 glow buttons, automatically arranged. I created and assigned TActions for each of these buttons with simple code behind. The app then crashed on attempting to load this form.

This is the call stack and local watches at the point of the Access Violation/

The form with the TAdvPager as a ribbon control (Office 2019 White style) is on a secondary form in the application - i.e. not the main form. Also, the form is embedded in a container form (we can instantiate multiple types of forms in that place)

If you can shed any light on why this might be happening with just a simple addition to the ribbon, I'd be grateful. As I said, it's happened randomly with remote beta users, but we've never experienced in-house before.

You'll understand that the creation of a sample project isn't possible, and confidentiality & complexity prohibits the sharing of this application, the DFM of the offending form is here: frmWorkshop1.DFM - Pastebin.com

The tbDraw TAdvToolbar was the only addition since the previously working version, and it was moved from toolbarindex 2 to 1

Regards, Stuart

Delphi 10.3
TMS VCL UI Pack 13.5

Update

I've tracked this down to the designtime width of the containing form being too narrow. I widened the designtime form and it nows loads. The runtime width is different, and set consistently at runtime.

I'd still consider this a bug - it should be able to deal with designtime width.

Cheers

Strange.
Can you isolate this and send a test project with which we can reproduce this here?

Hi Bruno,

It's proving impossible to isolate this in a test case I'm afraid. Are you able to give any pointers as to why this might be happening?

We worked around this by ensuring the design time width of the form containing the TAdvToolbarPager was wide enough to show all TAdvToolbars. But now I've had a user contact me with the same bug -- because their display scale was 200%. When they use the same application version on their laptop with 100% scaling the app doesn't crash.

It appears that TCompactWindow.CreateParams is being triggered possibly too early - such that there's no scrollbars, no owner - so it then causes access violations in normal TForm methods that expect scrollbars.

The bug is happening when I call Form.Show - the call stack shows it's coming from PopupControlProc - looks like the ribbon control isn't fully created when I call show (I'm not using threads or timers or anything like that).

The only other thing worth mentioning is that the form containing the ribbon is a child form hosted inside a parent container form (it has to live alongside a side-bar for data-entry). The form itself is one of 3 variants as part of a dynamic plug-in system.

Hope you can help or guide

Stuart

There are countless scenarios that make it impossible to guess what is going on. If you can't reproduce it yourself, that already indicates it is something non-trivial.
There are so many questions, like do you create everything at design-time or do you also do run-time creation, do you persist settings, do you have any event handlers that could interfere, etc etc..
So, I'd like to ask again to please send a test project with which we can reproduce this so we can test and investigate.

1 Like

Hi Bruno,

Thanks for the reply. I understand your requirements (mine are the same haha). Sadly, it's proving impossible to re-create in a test project. I'm creating all forms at runtime, the forms have all the controls created at designtime.

I will carry on testing here -- I think it maybe something to do with the form containing the ribbon being embedded in another form and the order in which things are done.

Thanks again,