Randomly firing form event: Why?

Windows
Version 22H2 Build 19045.5608
LO
Version: 24.8.5.2 (X86_64) / LibreOffice Community
Build ID: fddf2685c70b461e7832239a0162a77216259f22
CPU threads: 2; OS: Windows 10 X86_64 (10.0 build 19045); UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: threaded

From the LibreOffice Base Guide, p. 457:

When a modified record is stored, there are two implementations involved named
org.openoffice.comp.svx.FormController and
com.sun.star.comp.forms.ODatabaseForm.

Each implementation causes the Before Record Action event to fire, so the event fires twice, sometimes. Only the FormController event fires consistently. For me, for the last couple of months, the ODatabaseForm hasn’t been firing at all. Tonight it suddenly started firing, generating some errors. That was easy to fix, but it left me wondering. Why does the ODatabaseForm event fire erratically, and what’s the point of having it fire at all if it doesn’t fire consistently?

My limited understanding is that LO Basic isn’t entirely thread safe.

The problem isn’t new, see for example:

https://www.developpez.net/forums/d1548759/logiciels/logiciels-libres-open-source/bureautique/openoffice-libreoffice/ordre-evenements-reentrance-macro-traitement-evemenents/

Re-entrant functions such as the one you highlight cause multiple firing, which can lead to desynchronisation, crashes and other generally unexpected behavior.

There doesn’t appear to be an easy way to solve the problem.

It is almost certainly a bug, which has unfortunately attracted little developer attention, probably because it is a complex area, and probably also considered to be a bit niche.

In macros i only use this:

IF oForm.ImplementationName = "org.openoffice.comp.svx.FormController" THEN
…
END IF

You could insert the code there and the boolean value will be set there also. If the boolean value is false it will EXIT FUNCTION. Also I know I could get the controls in the form with
oForm.Model.getString(oForm.Model.FindColumn("MyTablefield")). This only works with “org.openoffice.comp.svx.FormController” while
oForm.getString(oForm.FindColumn("MyTablefield")) will work with “com.sun.star.comp.forms.ODatabaseForm”.