Hello List,
I'm trying to get hold of an ScDocument "from scratch". I have naively
attempted to replicate another section of code, but for the life of me
can't figure out what I'm missing. My code crashes with a SIGSEGV on
this line:
aDocShell = new ScDocShell();
I think I've boiled it down to a null pointer dereference (see attached,
please), but that implies the existing code is incorrect, which I'm not
yet ready to admit.
Any pointers very welcome.
Thanks,
Kevin
// ----- My code ...
[...]
#include "docsh.hxx"
[...]
SomeClass::SomeClass ( ) {
printf("Step 1: Construction ... ");
fflush( stdout );
// This call dies, but I don't understand why. I've traced it to
// 'getComponentContext' returning a NULL pointer, and below.
m_pDocSh = new ScDocShell();
printf("done.\n"); // <-- this line never reached, as a SIGSEGV occurs
}
//
// In case it's pertinent, here's is the call stack at time of SIGSEGV:
//
// SvtViewOptionsBase_Impl::SvtViewOptionsBase_Impl(rtl::OUString const&)
(viewoptions.cxx:367)
// SvtViewOptions::AcquireOptions() (viewoptions.cxx:1246)
// SfxApplication::SfxApplication() (app.cxx:314)
// SfxApplication::GetOrCreate() (app.cxx:278)
// SfxGetpApp() (app.hxx:288)
// SfxObjectShell_Impl::SfxObjectShell_Impl(SfxObjectShell&) (objxtor.cxx:287)
// SfxObjectShell::SfxObjectShell(unsigned long) (objxtor.cxx:302)
// ScDocShell::ScDocShell(unsigned long)
// ... a few more irrelevant stack pieces
//
// ----- Tracings through LO code
// (I start tracing below within unotools/source/config/viewoptions.cxx )
//
// comphelper/source/processfactory/processfactory.cxx:getComponentContext
{
Reference< XComponentContext > xRet;
// [...]
return xRet; // at this point, xRet is NULL
}
//
// Which then makes this pass a NULL to theDefaultProvider::get
//
css::uno::Reference< css::uno::XInterface > ConfigurationHelper::openConfig(
const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR,
const ::rtl::OUString& sPackage,
sal_Int32 eMode
) {
css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider(
css::configuration::theDefaultProvider::get(
getComponentContext( xSMGR )
)
);
// [...]
}
//
// theDefaultProvider::Get then tries to use the NULL pointer:
//
class theDefaultProvider {
public:
static ::com::sun::star::uno::Reference<
::com::sun::star::lang::XMultiServiceFactory > get(
::com::sun::star::uno::Reference<
::com::sun::star::uno::XComponentContext > const & context
) {
::com::sun::star::uno::Reference<
::com::sun::star::lang::XMultiServiceFactory > instance;
// This line is what appears to fail, as 'context' is currently
a
// NULL pointer
if ( ! ( context->getValueByName(
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.configuration.theDefaultProvider")))
>>= instance) || !instance.is() )
throw
::com::sun::star::uno::DeploymentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("component
context fails to supply singleton
com.sun.star.configuration.theDefaultProvider of type
com.sun.star.lang.XMultiServiceFactory")), context);
return instance;
}
// [...]
}
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice