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

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