Second Bootstrap Crashes OO

The Application Programming Interface and the OASIS Open Document Format

Second Bootstrap Crashes OO

Postby mavatar » Wed May 02, 2012 4:23 am

I have written a DLL in C++ that uses the UNO API to convert a Word document into HTML. I have run into an issue in which if I execute the program twice the second call crashes the already open OO process. I have tracked the crash down to the following bootstrap line of code.

Reference<XComponentContext> xComponentContext = ::cppu::bootstrap();

So on the first execution OO is not running, and the bootstrap launches an OO instance. After the conversion program terminates the OO process is still running. Upon the second execution the call to bootstrap appears to launch a second OO instance, and then I see both OO processes terminate.

I was under the impression that a second call to bootstrap would simply open a connection to the existing OO process. Is there something type of cleanup that should be executed when the program terminates, so that subsequent bootstraps don't cause OO to crash?
OpenOffice 3.3 / Windows 7
mavatar
 
Posts: 3
Joined: Wed May 02, 2012 4:12 am

Re: Second Bootstrap Crashes OO

Postby mavatar » Wed May 02, 2012 4:42 am

Some addtional information... If a add the following lines of code to my program, which essentially terminates the OO process, the second call to bootstrap works as expected, a new OO instance is launched.

Reference<XDesktop> xDesktop(xServiceManager->createInstanceWithContext(
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")), xComponentContext), UNO_QUERY_THROW);
xDesktop->terminate();

Also if I leave the first program that creates the OO instance sitting at a break point before it disposes the service manager, opening another instance of the program is able to successfully connect to the OO instance via bootstrap. However, as soon as the first process disposes the service manager. The second call to bootstrap causes the OO process to crash (or terminate).
OpenOffice 3.3 / Windows 7
mavatar
 
Posts: 3
Joined: Wed May 02, 2012 4:12 am

Re: Second Bootstrap Crashes OO

Postby mavatar » Wed May 02, 2012 4:56 am

I've also found that if my program simply calls the cppu::bootstrap function and nothing else, the second program execution is successful. However, if I add the following lines of code to my program, the second bootstrap is problematic.

Reference<XMultiComponentFactory> xServiceManager(xComponentContext->getServiceManager());
Reference<XComponent>::query(xServiceManager)->dispose();

So it seems to have something to do with getting a reference to the service manager, and then disposing of it, that causes the subsequent bootstrap to crash the OO instance.
OpenOffice 3.3 / Windows 7
mavatar
 
Posts: 3
Joined: Wed May 02, 2012 4:12 am


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 2 guests