135360
From 9b6a3417e3a6190f356e9f608346d5ee07bbd19d Mon Sep 17 00:00:00 2001
135360
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
135360
Date: Sat, 19 Dec 2015 15:11:03 +0000
135360
Subject: [PATCH 380/398] coverity#1343633 Resource leak
135360
135360
Change-Id: I2384091557c2a3b061e2c60118309f35b65b45d6
135360
(cherry picked from commit 746da6b7fb3829e1ca23a4b8dfec6c502bac681c)
135360
Reviewed-on: https://gerrit.libreoffice.org/21270
135360
Reviewed-by: David Tardon <dtardon@redhat.com>
135360
Tested-by: Jenkins <ci@libreoffice.org>
135360
(cherry picked from commit af32996eb55008b9787516a280a237b61a05ca05)
135360
---
135360
 libreofficekit/source/gtk/lokdocview.cxx | 14 ++++++--------
135360
 1 file changed, 6 insertions(+), 8 deletions(-)
135360
135360
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
135360
index ec3eb4b9e3ba..4d2842005f37 100644
135360
--- a/libreofficekit/source/gtk/lokdocview.cxx
135360
+++ b/libreofficekit/source/gtk/lokdocview.cxx
135360
@@ -335,6 +335,9 @@ static void
135360
 doSearch(LOKDocView* pDocView, const char* pText, bool bBackwards, bool highlightAll)
135360
 {
135360
     LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
+    if (!priv->m_pDocument)
135360
+        return;
135360
+
135360
     boost::property_tree::ptree aTree;
135360
     GtkWidget* drawingWidget = GTK_WIDGET(pDocView);
135360
     GdkWindow* drawingWindow = gtk_widget_get_window(drawingWidget);
135360
@@ -342,9 +345,6 @@ doSearch(LOKDocView* pDocView, const char* pText, bool bBackwards, bool highligh
135360
     cairo_rectangle_int_t cairoVisRect;
135360
     int x, y;
135360
 
135360
-    if (!priv->m_pDocument)
135360
-        return;
135360
-
135360
     cairo_region_get_rectangle(cairoVisRegion, 0, &cairoVisRect);
135360
     x = pixelToTwip (cairoVisRect.x, priv->m_fZoom);
135360
     y = pixelToTwip (cairoVisRect.y, priv->m_fZoom);
135360
@@ -2541,13 +2541,13 @@ SAL_DLLPUBLIC_EXPORT void
135360
 lok_doc_view_set_part (LOKDocView* pDocView, int nPart)
135360
 {
135360
     LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
+    if (!priv->m_pDocument)
135360
+        return;
135360
+
135360
     GTask* task = g_task_new(pDocView, nullptr, nullptr, nullptr);
135360
     LOEvent* pLOEvent = new LOEvent(LOK_SET_PART);
135360
     GError* error = nullptr;
135360
 
135360
-    if (!priv->m_pDocument)
135360
-        return;
135360
-
135360
     pLOEvent->m_nPart = nPart;
135360
     g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
135360
 
135360
@@ -2564,7 +2564,6 @@ SAL_DLLPUBLIC_EXPORT gchar*
135360
 lok_doc_view_get_part_name (LOKDocView* pDocView, int nPart)
135360
 {
135360
     LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
-
135360
     if (!priv->m_pDocument)
135360
         return nullptr;
135360
 
135360
@@ -2680,7 +2679,6 @@ lok_doc_view_post_command (LOKDocView* pDocView,
135360
                            gboolean bNotifyWhenFinished)
135360
 {
135360
     LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
-
135360
     if (!priv->m_pDocument)
135360
         return;
135360
 
135360
-- 
135360
2.12.0
135360