Blame SOURCES/0271-lok-Fix-crash-due-to-non-initialized-callback.patch

f325b2
From d048d2bb9464d5bb86b37e7da436be6ffe13ab29 Mon Sep 17 00:00:00 2001
f325b2
From: Jan Holesovsky <kendy@collabora.com>
f325b2
Date: Tue, 3 Nov 2015 16:52:46 +0100
f325b2
Subject: [PATCH 271/398] lok: Fix crash due to non-initialized callback.
f325b2
f325b2
Yay for unit tests! :-)
f325b2
f325b2
Change-Id: I06b3f929b53d5c03f5722acfdaf0eaf841325e34
f325b2
(cherry picked from commit b846b03c709130564527da8d264660a131361221)
f325b2
---
f325b2
 desktop/qa/desktop_lib/test_desktop_lib.cxx | 15 ++++++++++++---
f325b2
 desktop/source/lib/init.cxx                 |  6 ++++--
f325b2
 2 files changed, 16 insertions(+), 5 deletions(-)
f325b2
f325b2
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
f325b2
index 15fe123fdc37..4c23ecb50b73 100644
f325b2
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
f325b2
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
f325b2
@@ -394,16 +394,25 @@ void DesktopLOKTest::testRowColumnHeaders()
f325b2
 void DesktopLOKTest::testCommandResult()
f325b2
 {
f325b2
     LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
f325b2
-    pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
f325b2
 
f325b2
     // the postUnoCommand() is supposed to be async, let's test it safely
f325b2
     // [no idea if it is async in reality - most probably we are operating
f325b2
     // under some solar mutex or something anyway ;-) - but...]
f325b2
-    m_aCommandResultCondition.reset();
f325b2
+    TimeValue aTimeValue = { 2 , 0 }; // 2 seconds max
f325b2
 
f325b2
+    // nothing is triggered when we have no callback yet, we just time out on
f325b2
+    // the condition var.
f325b2
+    m_aCommandResultCondition.reset();
f325b2
     pDocument->pClass->postUnoCommand(pDocument, ".uno:Bold", 0, true);
f325b2
+    m_aCommandResultCondition.wait(aTimeValue);
f325b2
 
f325b2
-    TimeValue aTimeValue = { 2 , 0 }; // 2 seconds max
f325b2
+    CPPUNIT_ASSERT(m_aCommandResult.isEmpty());
f325b2
+
f325b2
+    // but we get some real values when the callback is set up
f325b2
+    pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
f325b2
+
f325b2
+    m_aCommandResultCondition.reset();
f325b2
+    pDocument->pClass->postUnoCommand(pDocument, ".uno:Bold", 0, true);
f325b2
     m_aCommandResultCondition.wait(aTimeValue);
f325b2
 
f325b2
     boost::property_tree::ptree aTree;
f325b2
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
f325b2
index b9aeedd5e21c..bf244cd7aefa 100644
f325b2
--- a/desktop/source/lib/init.cxx
f325b2
+++ b/desktop/source/lib/init.cxx
f325b2
@@ -268,8 +268,10 @@ static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
f325b2
 static int doc_getView(LibreOfficeKitDocument* pThis);
f325b2
 static int doc_getViews(LibreOfficeKitDocument* pThis);
f325b2
 
f325b2
-LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) :
f325b2
-    mxComponent( xComponent )
f325b2
+LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent)
f325b2
+    : mxComponent(xComponent)
f325b2
+    , mpCallback(nullptr)
f325b2
+    , mpCallbackData(nullptr)
f325b2
 {
f325b2
     if (!(m_pDocumentClass = gDocumentClass.lock()))
f325b2
     {
f325b2
-- 
f325b2
2.12.0
f325b2