dialog called from toolbar may cause LO to crash on exit

Not a bug report, a question on a possible fix.

I’m using code modeled after the .ods file at How to make non-modal dialog?
In this code a nonmodal dialog is launched from a button on a sheet. It works fine, and my code works fine, mostly.

But if the sub containing the load dialog code is launched from a button on the standard toolbar, and if I then close LO without closing the dialog, LO will crash every time. “Due to an error, LibreOffice crashed…” This will also happen if the code is called with Tools->Macro->Run Macro. But if the Basic editor is open, the spreadsheet (thiscomponent) will close properly and not crash.

I’m guessing I need to put my dialog into some kind of container but I don’t know how to do this and I could use a few lines of example. Or is there some other solution?

thanks for any help,

-dave

[update]

tried

  window = CreateUnoService("com.sun.star.awt.Toolkit")
  dialog.createPeer(window, null)

which didn’t help. also note this info

LO Version: 6.3.5.2
Build ID: 1:6.3.5~rc2-0ubuntu0.18.04.1~lo1
CPU threads: 4; OS: Linux 5.3; UI render: default; VCL: gtk3;

[ update ]
here is minimal sample code
dlgcrashtest.ods

Not a bug report

It should be one.

more update
https://bugs.documentfoundation.org/show_bug.cgi?id=126094

a workaround is to start a script from the command line. if the script loads the dialog, LO will not crash on close.
$ soffice “vnd.sun.star.script:LIBNAME.MODULENAME.SUBNAME?language=Basic&location=document” “MYDOC.ODS”