Kaydet (Commit) b846b03c authored tarafından Jan Holesovsky's avatar Jan Holesovsky

lok: Fix crash due to non-initialized callback.

Yay for unit tests! :-)

Change-Id: I06b3f929b53d5c03f5722acfdaf0eaf841325e34
üst a4988d22
...@@ -394,16 +394,25 @@ void DesktopLOKTest::testRowColumnHeaders() ...@@ -394,16 +394,25 @@ void DesktopLOKTest::testRowColumnHeaders()
void DesktopLOKTest::testCommandResult() void DesktopLOKTest::testCommandResult()
{ {
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
// the postUnoCommand() is supposed to be async, let's test it safely // the postUnoCommand() is supposed to be async, let's test it safely
// [no idea if it is async in reality - most probably we are operating // [no idea if it is async in reality - most probably we are operating
// under some solar mutex or something anyway ;-) - but...] // under some solar mutex or something anyway ;-) - but...]
m_aCommandResultCondition.reset(); TimeValue aTimeValue = { 2 , 0 }; // 2 seconds max
// nothing is triggered when we have no callback yet, we just time out on
// the condition var.
m_aCommandResultCondition.reset();
pDocument->pClass->postUnoCommand(pDocument, ".uno:Bold", 0, true); pDocument->pClass->postUnoCommand(pDocument, ".uno:Bold", 0, true);
m_aCommandResultCondition.wait(aTimeValue);
TimeValue aTimeValue = { 2 , 0 }; // 2 seconds max CPPUNIT_ASSERT(m_aCommandResult.isEmpty());
// but we get some real values when the callback is set up
pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
m_aCommandResultCondition.reset();
pDocument->pClass->postUnoCommand(pDocument, ".uno:Bold", 0, true);
m_aCommandResultCondition.wait(aTimeValue); m_aCommandResultCondition.wait(aTimeValue);
boost::property_tree::ptree aTree; boost::property_tree::ptree aTree;
......
...@@ -269,8 +269,10 @@ static void doc_setView(LibreOfficeKitDocument* pThis, int nId); ...@@ -269,8 +269,10 @@ static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
static int doc_getView(LibreOfficeKitDocument* pThis); static int doc_getView(LibreOfficeKitDocument* pThis);
static int doc_getViews(LibreOfficeKitDocument* pThis); static int doc_getViews(LibreOfficeKitDocument* pThis);
LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) : LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent)
mxComponent( xComponent ) : mxComponent(xComponent)
, mpCallback(nullptr)
, mpCallbackData(nullptr)
{ {
if (!(m_pDocumentClass = gDocumentClass.lock())) if (!(m_pDocumentClass = gDocumentClass.lock()))
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment