summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2020-03-05 12:18:38 +0100
committerSzymon Kłos <eszkadev@gmail.com>2020-05-18 17:52:21 +0200
commit4134777711854ed68a7c2ffbd42cc118efd62184 (patch)
treeae6c808f09964e3cc10f3b1549767b505a9be115
parent3d2be32a12708e43158f2a490bde24aae8f11f9e (diff)
jsdialog: Remember builder connected with LOK window id
Change-Id: I9e38fe570b2296341c1694fe8128da30ba209494 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94184 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r--compilerplugins/clang/badstatics.cxx1
-rw-r--r--include/vcl/jsdialog/jsdialogbuilder.hxx (renamed from vcl/inc/jsdialog/jsdialogbuilder.hxx)12
-rw-r--r--include/vcl/salvtables.hxx (renamed from vcl/inc/salvtables.hxx)0
-rw-r--r--vcl/jsdialog/jsdialogbuilder.cxx31
-rw-r--r--vcl/source/app/salvtables.cxx2
-rw-r--r--vcl/source/window/builder.cxx2
6 files changed, 42 insertions, 6 deletions
diff --git a/compilerplugins/clang/badstatics.cxx b/compilerplugins/clang/badstatics.cxx
index 737330dd10c0..7c595f77207a 100644
--- a/compilerplugins/clang/badstatics.cxx
+++ b/compilerplugins/clang/badstatics.cxx
@@ -205,6 +205,7 @@ public:
|| (loplugin::DeclCheck(pVarDecl).Var("maThreadSpecific")
.Class("ScDocument").GlobalNamespace()) // not owning
|| name == "s_aLOKWindowsMap" // LOK only, guarded by assert, and LOK never tries to perform a VCL cleanup
+ || name == "s_aLOKWeldBuildersMap" // LOK only, similar case as above
|| name == "gStaticManager" // vcl/source/graphic/Manager.cxx - stores non-owning pointers
|| name == "aThreadedInterpreterPool" // ScInterpreterContext(Pool), not owning
|| name == "aNonThreadedInterpreterPool" // ScInterpreterContext(Pool), not owning
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx
index 0104756b7b55..b26b2ac2ff16 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/include/vcl/jsdialog/jsdialogbuilder.hxx
@@ -6,7 +6,7 @@
#include <vcl/sysdata.hxx>
#include <vcl/virdev.hxx>
#include <vcl/builder.hxx>
-#include <salvtables.hxx>
+#include <vcl/salvtables.hxx>
#include <vcl/combobox.hxx>
#include <vcl/button.hxx>
@@ -25,8 +25,11 @@ public:
class VCL_DLLPUBLIC JSInstanceBuilder : public SalInstanceBuilder
{
+ vcl::LOKWindowId m_nWindowId;
+
public:
JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
+ virtual ~JSInstanceBuilder() override;
virtual std::unique_ptr<weld::Dialog> weld_dialog(const OString& id,
bool bTakeOwnership = true) override;
virtual std::unique_ptr<weld::Label> weld_label(const OString& id,
@@ -39,10 +42,13 @@ public:
bool bTakeOwnership = false) override;
virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString& id,
bool bTakeOwnership = false) override;
+
+ static std::map<vcl::LOKWindowId, JSInstanceBuilder*>& GetLOKWeldBuilderMap();
+ static JSInstanceBuilder* FindLOKWeldBuilder(vcl::LOKWindowId nWindowId);
};
template <class BaseInstanceClass, class VclClass>
-class JSWidget : public BaseInstanceClass, public JSDialogSender
+class VCL_DLLPUBLIC JSWidget : public BaseInstanceClass, public JSDialogSender
{
public:
JSWidget(VclPtr<vcl::Window> aOwnedToplevel, VclClass* pObject, SalInstanceBuilder* pBuilder,
@@ -130,4 +136,4 @@ public:
virtual void append_page(const OString& rIdent, const OUString& rLabel) override;
};
-#endif \ No newline at end of file
+#endif
diff --git a/vcl/inc/salvtables.hxx b/include/vcl/salvtables.hxx
index 6222423551bc..6222423551bc 100644
--- a/vcl/inc/salvtables.hxx
+++ b/include/vcl/salvtables.hxx
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 64f78c295bed..901f92aac109 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -1,4 +1,4 @@
-#include <jsdialog/jsdialogbuilder.hxx>
+#include <vcl/jsdialog/jsdialogbuilder.hxx>
#include <sal/log.hxx>
#include <boost/property_tree/json_parser.hpp>
#include <comphelper/lok.hxx>
@@ -30,12 +30,41 @@ JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIR
? dynamic_cast<SalInstanceWidget*>(pParent)->getWidget()
: nullptr,
rUIRoot, rUIFile)
+ , m_nWindowId(0)
{
}
+JSInstanceBuilder::~JSInstanceBuilder()
+{
+ if (m_nWindowId)
+ GetLOKWeldBuilderMap().erase(m_nWindowId);
+}
+
+std::map<vcl::LOKWindowId, JSInstanceBuilder*>& JSInstanceBuilder::GetLOKWeldBuilderMap()
+{
+ // Map to remember the LOKWindowId <-> Builder binding.
+ static std::map<vcl::LOKWindowId, JSInstanceBuilder*> s_aLOKWeldBuildersMap;
+
+ return s_aLOKWeldBuildersMap;
+}
+
+JSInstanceBuilder* JSInstanceBuilder::FindLOKWeldBuilder(vcl::LOKWindowId nWindowId)
+{
+ const auto it = GetLOKWeldBuilderMap().find(nWindowId);
+ if (it != GetLOKWeldBuilderMap().end())
+ return it->second;
+
+ return nullptr;
+}
+
std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id, bool bTakeOwnership)
{
::Dialog* pDialog = m_xBuilder->get<::Dialog>(id);
+ m_nWindowId = pDialog->GetLOKWindowId();
+
+ GetLOKWeldBuilderMap().insert(
+ std::map<vcl::LOKWindowId, JSInstanceBuilder*>::value_type(m_nWindowId, this));
+
std::unique_ptr<weld::Dialog> pRet(pDialog ? new SalInstanceDialog(pDialog, this, false)
: nullptr);
if (bTakeOwnership && pDialog)
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 77334c1cc90d..e4f576201514 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -71,7 +71,7 @@
#include <aboutdialog.hxx>
#include <bitmaps.hlst>
#include <wizdlg.hxx>
-#include <salvtables.hxx>
+#include <vcl/salvtables.hxx>
SalFrame::SalFrame()
: m_pWindow(nullptr)
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 184313b8c12c..eb87ea7403f2 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -65,7 +65,7 @@
#include <wizdlg.hxx>
#include <tools/svlibrary.h>
#include <comphelper/lok.hxx>
-#include <jsdialog/jsdialogbuilder.hxx>
+#include <vcl/jsdialog/jsdialogbuilder.hxx>
#if defined(DISABLE_DYNLOADING) || defined(LINUX)
#include <dlfcn.h>