forked from amazingfate/loongoffice
Using an external (Java) script that opens a document, and then quickly closes it, it may happen that the idle that generates a preview is still active, when the control thread calls XCloseable::close, which destroys still used document. This leads to use-after-free. This uses the close listener in SfxObjectShell, to veto closing document that is still in use by the preview generation code. After completion, when the caller of close() transferred ownership, then the call to close is repeated. Change-Id: I39691f61ad5141d7e8ee54723d5aef87f0bc01dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164632 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>