summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2017-11-29 14:19:54 +0100
committerpranavk <pranavk@collabora.co.uk>2018-01-18 08:27:36 +0100
commitbfbed0f9c4ab52e770ef8b37e6a6328991cd0c6b (patch)
treed70f5207557aa6575adff69e357d7236e9f0a064 /vcl/source
parent778c9d539326309abc93652cc06fbe8b28c8a0a1 (diff)
lokdialog: Make the badstatic loplugin happy.
Change-Id: Ic19bbd2a3533e4e600d8856e55c4e8d06f0ad752 Reviewed-on: https://gerrit.libreoffice.org/45500 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan Holesovsky <kendy@collabora.com> (cherry picked from commit 8ce967ad157d83ad567c5f8c750f4225dd974219) Reviewed-on: https://gerrit.libreoffice.org/48088 Reviewed-by: pranavk <pranavk@collabora.co.uk> Tested-by: pranavk <pranavk@collabora.co.uk>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/window/window.cxx37
1 files changed, 27 insertions, 10 deletions
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 430dbe3ac2cf..f0ab681f421f 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -85,12 +85,6 @@ using namespace ::com::sun::star::datatransfer::dnd;
namespace vcl {
-/// Counter to be able to have unique id's for each window.
-static vcl::LOKWindowId sLastLOKWindowId = 1;
-
-/// Map to remember the LOKWindowId <-> Window binding.
-static std::map<vcl::LOKWindowId, VclPtr<vcl::Window>> sLOKWindows;
-
Window::Window( WindowType nType ) :
mpWindowImpl(new WindowImpl( nType ))
{
@@ -3200,24 +3194,47 @@ void Window::SetComponentInterface( Reference< css::awt::XWindowPeer > const & x
pWrapper->SetWindowInterface( this, xIFace );
}
+typedef std::map<vcl::LOKWindowId, VclPtr<vcl::Window>> LOKWindowsMap;
+
+namespace {
+
+LOKWindowsMap& GetLOKWindowsMap()
+{
+ // never use this in the desktop case
+ assert(comphelper::LibreOfficeKit::isActive());
+
+ // Map to remember the LOKWindowId <-> Window binding.
+ static std::unique_ptr<LOKWindowsMap> s_pLOKWindowsMap;
+
+ if (!s_pLOKWindowsMap)
+ s_pLOKWindowsMap.reset(new LOKWindowsMap);
+
+ return *s_pLOKWindowsMap.get();
+}
+
+}
+
void Window::SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier)
{
// don't allow setting this twice
assert(mpWindowImpl->mpLOKNotifier == nullptr);
assert(pNotifier);
+ // Counter to be able to have unique id's for each window.
+ static vcl::LOKWindowId sLastLOKWindowId = 1;
+
// assign the LOK window id
assert(mpWindowImpl->mnLOKWindowId == 0);
mpWindowImpl->mnLOKWindowId = sLastLOKWindowId++;
- sLOKWindows.insert(std::map<vcl::LOKWindowId, VclPtr<vcl::Window>>::value_type(mpWindowImpl->mnLOKWindowId, this));
+ GetLOKWindowsMap().insert(std::map<vcl::LOKWindowId, VclPtr<vcl::Window>>::value_type(mpWindowImpl->mnLOKWindowId, this));
mpWindowImpl->mpLOKNotifier = pNotifier;
}
VclPtr<Window> Window::FindLOKWindow(vcl::LOKWindowId nWindowId)
{
- const auto it = sLOKWindows.find(nWindowId);
- if (it != sLOKWindows.end())
+ const auto it = GetLOKWindowsMap().find(nWindowId);
+ if (it != GetLOKWindowsMap().end())
return it->second;
return VclPtr<Window>();
@@ -3227,7 +3244,7 @@ void Window::ReleaseLOKNotifier()
{
// unregister the LOK window binding
if (mpWindowImpl->mnLOKWindowId > 0)
- sLOKWindows.erase(mpWindowImpl->mnLOKWindowId);
+ GetLOKWindowsMap().erase(mpWindowImpl->mnLOKWindowId);
mpWindowImpl->mpLOKNotifier = nullptr;
mpWindowImpl->mnLOKWindowId = 0;