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