How LO termination could be correctly called during XPackageEncryption service process?

How LO termination could be correctly called during XPackageEncryption service process?

I write addon using C++ and I can’t find any proper solution how to terminate LO though the code if I need.

destop->terminate() returns false, so there’s no effect

as workaround I can throw an exception and then std::terminate would be called, but memory leaks are possible.

Memory leaks after OS has terminated the process?

You are right, I should be more precise. Resource leaks are possible.
If your destructor is used to cancel disk formatting, it wouldn’t be called after std::terminate.

Of course in modern OS, when a process dies, OS would release all of its memory. But it’s not C++ way of resource managing.

That’s why I’m asking if there’s any proper way to call LO termination, when some service is being executed.

It’s not quite clear what “XPackageEncryption service process” might mean specifically - maybe you refer to XPackageEncryption::encrypt or XPackageEncryption::decrypt, which are likely the most time-consuming methods of the interface?

Then - the methods are synchronous, and there exist no provisions for interrupting them. So your only options are waiting for their completion, or using the process termination.

This kind of questions is better asked in places where development is discussed (IRC or mailing lists); if you need such a feature, you may create a patch introducing an extended XPackageEncryption2 interface, providing some async/interruptible versions of the methods. We welcome anyone who wants to hack on LibreOffice code, and can provide necessary mentoring.

And please think twice before shutting down LO instead of closing “your” document. When taking calls I often “work” with several open files/documents and don’t like unnecessary restarts of all files…

Yep, sorry, I mean indeed closing the document as you have mentioned.

Thank you, I see now. I mean encrypt, decrypt and the others methods as well.
After your and @Wanderer answers I’m not sure if I’m going right direction.

Here is the problem I’m trying to solve. If an error occurs when processing encrypted file, I want custom message box to be shown and then close the document. It would be perfect to have some EncryptionListener which can show a message box and close the document.

Sorry, IRC channel is not always convenient enough for my opinion. Can miss some answers due to disconnections. Discord or any modern chat is preferable option.
I have created discord server for LibreOffice LibreOffice++, so anyone is welcome.

As hack, I would like to migrate examples part of LO from make to CMake. I successfully migrate from make to CMake in my LO pet project (target OS - Windows, Linux, MacOS), so I’d happy to do it. I believe it would make things easier.