[Libreoffice-commits] core.git: 3 commits - libreofficekit/source

Pranav Kant pranavk at collabora.com
Sun Feb 21 16:45:54 UTC 2016


 libreofficekit/source/gtk/lokdocview.cxx |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

New commits:
commit f4e13bc973ed50bed80f2833dc8e5bc7a69bb44e
Author: Pranav Kant <pranavk at collabora.com>
Date:   Sun Feb 21 01:28:56 2016 +0530

    tdf#97235: Protect reset_view when called with no tile buffer initialized
    
    This can happen when no document has been loaded yet.
    
    Change-Id: Ib9c18e22b6c344528d05eb781bf9b3052060089a

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index e771b05..3ecf52c 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2825,7 +2825,9 @@ SAL_DLLPUBLIC_EXPORT void
 lok_doc_view_reset_view(LOKDocView* pDocView)
 {
     LOKDocViewPrivate& priv = getPrivate(pDocView);
-    priv->m_pTileBuffer->resetAllTiles();
+
+    if (priv->m_pTileBuffer != nullptr)
+        priv->m_pTileBuffer->resetAllTiles();
     priv->m_nLoadProgress = 0.0;
 
     memset(&priv->m_aVisibleCursor, 0, sizeof(priv->m_aVisibleCursor));
commit dbd7ce16d621bf992a763317174c85a5d9f3b5ea
Author: Pranav Kant <pranavk at collabora.com>
Date:   Sun Feb 21 00:14:29 2016 +0530

    tdf#97236: Refresh the view when part is changed
    
    Change-Id: I189d33cd25f394f5740d54fb5fe5567ac71299e4

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 059401a..e771b05 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1793,6 +1793,8 @@ setPartInThread(gpointer data)
 
     priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
     priv->m_pDocument->pClass->setPart( priv->m_pDocument, nPart );
+
+    lok_doc_view_reset_view(pDocView);
 }
 
 static void
commit 60b1fb6edb9aba1ac42d80697d73a9ee693ff45c
Author: Pranav Kant <pranavk at collabora.com>
Date:   Sat Feb 20 23:45:24 2016 +0530

    lokdocview: Protect set_part from setting an invalid part number
    
    Change-Id: Iffbe71ab161d5c50a98fd17ee0fdd0ab4d065e9d

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index baa4f6e..059401a 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -67,6 +67,8 @@ struct LOKDocViewPrivateImpl
     gboolean m_bEdit;
     /// LOK Features
     guint64 m_nLOKFeatures;
+    /// Number of parts in currently loaded document
+    gint m_nParts;
     /// Position and size of the visible cursor.
     GdkRectangle m_aVisibleCursor;
     /// Cursor overlay is visible or hidden (for blinking).
@@ -825,6 +827,7 @@ static gboolean postDocumentLoad(gpointer pData)
     priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument, priv->m_aRenderingArguments.c_str());
     priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, callbackWorker, pLOKDocView);
     priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, &priv->m_nDocumentWidthTwips, &priv->m_nDocumentHeightTwips);
+    priv->m_nParts = priv->m_pDocument->pClass->getParts(priv->m_pDocument);
     g_timeout_add(600, handleTimeout, pLOKDocView);
 
     float zoom = priv->m_fZoom;
@@ -2759,6 +2762,12 @@ lok_doc_view_set_part (LOKDocView* pDocView, int nPart)
     if (!priv->m_pDocument)
         return;
 
+    if (nPart < 0 || nPart >= priv->m_nParts)
+    {
+        g_warning("Invalid part request : %d", nPart);
+        return;
+    }
+
     GTask* task = g_task_new(pDocView, nullptr, nullptr, nullptr);
     LOEvent* pLOEvent = new LOEvent(LOK_SET_PART);
     GError* error = nullptr;


More information about the Libreoffice-commits mailing list