uitest/EventListener: Set executed flag after storing event details

Most of the uses of the EventListener wait for the executed flag to be
set in a check-sleep loop. If the code then tries to access properties
of the listener such as the supplements array then there was a race
condition where the waiting thread might wake up in between the time
that the executed flag is set and the details are filled in. This can
happen for example in open_subcomponent_through_command. I can replicate
this problem locally by adding a short sleep after setting executed to
True.

This is likely the cause of build failures such as the following:

https://ci.libreoffice.org/job/gerrit_linux_clang_dbgutil/194139/

This patch just changes the order so that the executed flag is only set
after the event details are filled in.

Change-Id: I9ba108bc2e2fa084fd5d9e3048e34203feaa74a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195483
Tested-by: Jenkins
Reviewed-by: Neil Roberts <bpeeluk@yahoo.co.uk>
This commit is contained in:
Neil Roberts
2025-12-12 09:01:14 +01:00
parent 37c4a771b9
commit 911502799b
+1 -1
View File
@@ -40,9 +40,9 @@ class EventListener(XDocumentEventListener,unohelper.Base):
print("documentEventOccured: name=" + event.EventName + ", title=" + str(event.Supplement))
print("documentEventOccured: found event we are waiting for")
if event.EventName in self.eventNames:
self.executed = True
self.eventExecuted.append(event.EventName)
self.supplements.append(event.Supplement)
self.executed = True
def hasExecuted(self, eventName):
return eventName in self.eventExecuted