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