summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2015-11-03 16:52:46 +0100
committerJan Holesovsky <kendy@collabora.com>2015-11-03 18:33:47 +0100
commita280392afd084bed203ca83113a6671f8e258fea (patch)
treeb7204695346bdbf2a66bc1119817b66c1909e50d
parented68fb3ce45898577138f9713fbdc404073e4d2d (diff)
lok: Fix crash due to non-initialized callback.
Yay for unit tests! :-) Change-Id: I06b3f929b53d5c03f5722acfdaf0eaf841325e34
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx15
-rw-r--r--desktop/source/lib/init.cxx6
2 files changed, 16 insertions, 5 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 9cce4fb7e79f..e7d71bbd827b 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -400,16 +400,25 @@ void DesktopLOKTest::testRowColumnHeaders()
void DesktopLOKTest::testCommandResult()
{
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
// [no idea if it is async in reality - most probably we are operating
// 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);
+ 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);
boost::property_tree::ptree aTree;
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 72a217652998..8a391b389571 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -278,8 +278,10 @@ static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
static int doc_getView(LibreOfficeKitDocument* pThis);
static int doc_getViews(LibreOfficeKitDocument* pThis);
-LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) :
- mxComponent( xComponent )
+LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent)
+ : mxComponent(xComponent)
+ , mpCallback(nullptr)
+ , mpCallbackData(nullptr)
{
if (!(m_pDocumentClass = gDocumentClass.lock()))
{