summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-05-17 11:34:55 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-05-17 14:32:01 +0200
commitf7efddff6621e0c6f967f7159cf929a108285c34 (patch)
treea63ceaa10d1677afdc493ecd0400755cc4b2eb1d /filter
parentd21f97659e8ab8028deaa6d237caeeda088ddb1c (diff)
don't create a new ResMgr for each string
since... commit f3f71b087d25966d39a4c883bbe0b60b27419119 Date: Fri Nov 11 18:25:37 2016 +0100 Avoid -fsanitize=null ...during CppunitTest_filter_dialogs_test: Change-Id: I9c267816d013c27922621b6c8a75c53ce5b78bd8 Reviewed-on: https://gerrit.libreoffice.org/37704 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 'filter')
-rw-r--r--filter/source/xsltdialog/xmlfiltersettingsdialog.cxx28
-rw-r--r--filter/source/xsltdialog/xmlfiltersettingsdialog.hxx11
2 files changed, 31 insertions, 8 deletions
diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
index 490f3ad60f27..6bcd6f24fc7e 100644
--- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
+++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
@@ -61,16 +61,30 @@ using namespace com::sun::star::util;
using ::rtl::Uri;
namespace {
+ static ResMgr* pXSLTResMgr = nullptr;
-std::unique_ptr<ResMgr> getXSLTDialogResMgr() {
- return std::unique_ptr<ResMgr>(
- ResMgr::CreateResMgr(
- "xsltdlg", Application::GetSettings().GetUILanguageTag()));
+ ResMgr* getXSLTDialogResMgr()
+ {
+ return pXSLTResMgr;
+ }
+}
+
+EnsureResMgr::EnsureResMgr()
+{
+ if (!pXSLTResMgr)
+ {
+ m_xResMgr.reset(ResMgr::CreateResMgr("xsltdlg", Application::GetSettings().GetUILanguageTag()));
+ pXSLTResMgr = m_xResMgr.get();
+ }
}
+EnsureResMgr::~EnsureResMgr()
+{
+ if (m_xResMgr)
+ pXSLTResMgr = nullptr;
}
-#define RESID(x) ResId(x, *getXSLTDialogResMgr().get())
+#define RESID(x) ResId(x, *getXSLTDialogResMgr())
#define RESIDSTR(x) RESID(x).toString()
XMLFilterSettingsDialog::XMLFilterSettingsDialog(vcl::Window* pParent,
@@ -246,7 +260,7 @@ void XMLFilterSettingsDialog::onNew()
aTempInfo.maDocumentService = "com.sun.star.text.TextDocument";
// execute XML Filter Dialog
- ScopedVclPtrInstance< XMLFilterTabDialog > aDlg( this, *getXSLTDialogResMgr().get(), mxContext, &aTempInfo );
+ ScopedVclPtrInstance< XMLFilterTabDialog > aDlg( this, *getXSLTDialogResMgr(), mxContext, &aTempInfo );
if ( aDlg->Execute() == RET_OK )
{
// insert the new filter
@@ -265,7 +279,7 @@ void XMLFilterSettingsDialog::onEdit()
filter_info_impl* pOldInfo = static_cast<filter_info_impl*>(pEntry->GetUserData());
// execute XML Filter Dialog
- ScopedVclPtrInstance< XMLFilterTabDialog > aDlg( this, *getXSLTDialogResMgr().get(), mxContext, pOldInfo );
+ ScopedVclPtrInstance< XMLFilterTabDialog > aDlg( this, *getXSLTDialogResMgr(), mxContext, pOldInfo );
if ( aDlg->Execute() == RET_OK )
{
filter_info_impl* pNewInfo = aDlg->getNewFilterInfo();
diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.hxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.hxx
index 24617d0261fd..5105c67936c2 100644
--- a/filter/source/xsltdialog/xmlfiltersettingsdialog.hxx
+++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.hxx
@@ -55,11 +55,20 @@ public:
virtual bool EventNotify( NotifyEvent& rNEvt ) override;
};
+class EnsureResMgr
+{
+ std::unique_ptr<ResMgr> m_xResMgr;
+public:
+ EnsureResMgr();
+ ~EnsureResMgr();
+};
+
class HeaderBar;
class XMLFilterListBox : public SvTabListBox
{
private:
+ EnsureResMgr m_aEnsureResMgr;
VclPtr<HeaderBar> m_pHeaderBar;
DECL_LINK( TabBoxScrollHdl_Impl, SvTreeListBox*, void );
@@ -118,7 +127,7 @@ private:
OUString createUniqueInterfaceName( const OUString& rInterfaceName );
private:
-
+ EnsureResMgr maEnsureResMgr;
css::uno::Reference< css::uno::XComponentContext > mxContext;
css::uno::Reference< css::container::XNameContainer > mxFilterContainer;
css::uno::Reference< css::container::XNameContainer > mxTypeDetection;