summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-02-01 12:31:32 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-02-02 12:05:21 +0000
commit24c3426d07f5b8fcd19da6f4bc3ee7dd56758ab1 (patch)
treea272cefeaf79da37971d5eeea4a2f9d8acfbf00f /desktop
parentc3f09ae629b349c52a4a7954e3017ceb8d7afeaf (diff)
libreofficekit: fix inverted condition
... 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 <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx11
1 files changed, 7 insertions, 4 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 9d70ad2f5b6d..f7a40cb2abfe 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -33,6 +33,7 @@
#include <comphelper/lok.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
+#include <comphelper/scopeguard.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
@@ -533,6 +534,12 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
rtl::Reference<LOKInteractionHandler> 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<task::XInteractionHandler2> const xInteraction(pInteraction.get());
aFilterOptions[1].Name = "InteractionHandler";
aFilterOptions[1].Value <<= xInteraction;
@@ -553,10 +560,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())
{