[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - compilerplugins/clang include/vcl vcl/inc vcl/jsdialog vcl/source
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Fri May 15 11:04:56 UTC 2020
compilerplugins/clang/badstatics.cxx | 1 +
include/vcl/jsdialog/jsdialogbuilder.hxx | 12 +++++++++---
vcl/jsdialog/jsdialogbuilder.cxx | 31 ++++++++++++++++++++++++++++++-
vcl/source/app/salvtables.cxx | 2 +-
vcl/source/window/builder.cxx | 2 +-
5 files changed, 42 insertions(+), 6 deletions(-)
New commits:
commit bc6084026f188243ae9b33c8844854659dce2c84
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu Mar 5 12:18:38 2020 +0100
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri May 15 13:04:24 2020 +0200
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 at gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/compilerplugins/clang/badstatics.cxx b/compilerplugins/clang/badstatics.cxx
index d25b842da0d0..24e3946feabf 100644
--- a/compilerplugins/clang/badstatics.cxx
+++ b/compilerplugins/clang/badstatics.cxx
@@ -200,6 +200,7 @@ public:
|| (loplugin::DeclCheck(pVarDecl).Var("maThreadSpecific")
.Class("ScDocument").GlobalNamespace()) // not owning
|| name == "s_pLOKWindowsMap" // 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
similarity index 92%
rename from vcl/inc/jsdialog/jsdialogbuilder.hxx
rename to 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
similarity index 100%
rename from vcl/inc/salvtables.hxx
rename to 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 4700e7acc73f..2d49a95c2b7a 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -52,7 +52,7 @@
#include <vcl/toolkit/unowrap.hxx>
#include <vcl/weld.hxx>
#include <bitmaps.hlst>
-#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 9a9cb9af9ff1..36ca28e20f7e 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -62,7 +62,7 @@
#include <tools/svlibrary.h>
#include <tools/diagnose_ex.h>
#include <comphelper/lok.hxx>
-#include <jsdialog/jsdialogbuilder.hxx>
+#include <vcl/jsdialog/jsdialogbuilder.hxx>
#if defined(DISABLE_DYNLOADING) || defined(LINUX)
#include <dlfcn.h>
More information about the Libreoffice-commits
mailing list