f325b2
From 1404902fec558c589f17d757192548e009acdfc1 Mon Sep 17 00:00:00 2001
f325b2
From: Michael Stahl <mstahl@redhat.com>
f325b2
Date: Mon, 1 Feb 2016 12:31:32 +0100
f325b2
Subject: [PATCH 390/398] libreofficekit: fix inverted condition
f325b2
MIME-Version: 1.0
f325b2
Content-Type: text/plain; charset=UTF-8
f325b2
Content-Transfer-Encoding: 8bit
f325b2
f325b2
... that prevented loading the same URL multiple times.  Also make this
f325b2
exception-safe while at it.
f325b2
f325b2
(cherry picked from commit 61e80cd9e3e425674e18221237b8b0574645f377)
f325b2
f325b2
Change-Id: Ic71735fef1ad8f79a210279d4d03f1fd5fa8cf69
f325b2
Reviewed-on: https://gerrit.libreoffice.org/22001
f325b2
Tested-by: Jenkins <ci@libreoffice.org>
f325b2
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
f325b2
Tested-by: Caolán McNamara <caolanm@redhat.com>
f325b2
(cherry picked from commit 24c3426d07f5b8fcd19da6f4bc3ee7dd56758ab1)
f325b2
---
f325b2
 desktop/source/lib/init.cxx | 11 +++++++----
f325b2
 1 file changed, 7 insertions(+), 4 deletions(-)
f325b2
f325b2
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
f325b2
index 35ba91306036..fe297fb09414 100644
f325b2
--- a/desktop/source/lib/init.cxx
f325b2
+++ b/desktop/source/lib/init.cxx
f325b2
@@ -32,6 +32,7 @@
f325b2
 #include <comphelper/lok.hxx>
f325b2
 #include <comphelper/processfactory.hxx>
f325b2
 #include <comphelper/string.hxx>
f325b2
+#include <comphelper/scopeguard.hxx>
f325b2
 
f325b2
 #include <com/sun/star/beans/XPropertySet.hpp>
f325b2
 #include <com/sun/star/container/XNameAccess.hpp>
f325b2
@@ -531,6 +532,12 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
f325b2
         rtl::Reference<LOKInteractionHandler> const pInteraction(
f325b2
             new LOKInteractionHandler(::comphelper::getProcessComponentContext(), pLib));
f325b2
         auto const pair(pLib->mInteractionMap.insert(std::make_pair(aURL.toUtf8(), pInteraction)));
f325b2
+        comphelper::ScopeGuard const g([&] () {
f325b2
+                if (pair.second)
f325b2
+                {
f325b2
+                    pLib->mInteractionMap.erase(aURL.toUtf8());
f325b2
+                }
f325b2
+            });
f325b2
         uno::Reference<task::XInteractionHandler2> const xInteraction(pInteraction.get());
f325b2
         aFilterOptions[1].Name = "InteractionHandler";
f325b2
         aFilterOptions[1].Value <<= xInteraction;
f325b2
@@ -551,10 +558,6 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
f325b2
                                             aFilterOptions);
f325b2
 
f325b2
         assert(!xComponent.is() || pair.second); // concurrent loading of same URL ought to fail
f325b2
-        if (!pair.second)
f325b2
-        {
f325b2
-            pLib->mInteractionMap.erase(aURL.toUtf8());
f325b2
-        }
f325b2
 
f325b2
         if (!xComponent.is())
f325b2
         {
f325b2
-- 
f325b2
2.12.0
f325b2