summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-11-11 18:25:37 +0100
committerStephan Bergmann <sbergman@redhat.com>2016-11-14 17:45:17 +0100
commitf3f71b087d25966d39a4c883bbe0b60b27419119 (patch)
treed15d08119370a09fcb5a34217f617f76b7b24b30 /filter
parentc80ac2ba4a6486e6161e17f9118ba1563b7fc00e (diff)
Avoid -fsanitize=null
...during CppunitTest_filter_dialogs_test: > filter/source/xsltdialog/xmlfiltersettingsdialog.cxx:1398:20: runtime error: reference binding to null pointer of type 'ResMgr' > #0 0x7f144bf5ab10 in XMLFilterListBox::XMLFilterListBox(vcl::Window*, SvxPathControl*) filter/source/xsltdialog/xmlfiltersettingsdialog.cxx:1398:20 > #1 0x7f144bf7abb8 in VclPtr<XMLFilterListBox> VclPtr<XMLFilterListBox>::Create<VclPtr<VclVBox>&, SvxPathControl*>(VclPtr<VclVBox>&, SvxPathControl*&&) include/vcl/vclptr.hxx:138:46 > #2 0x7f144bf50df8 in SvxPathControl::SvxPathControl(vcl::Window*) filter/source/xsltdialog/xmlfiltersettingsdialog.cxx:1312:20 > #3 0x7f144bf7d487 in VclPtr<SvxPathControl> VclPtr<SvxPathControl>::Create<VclPtr<vcl::Window>&>(VclPtr<vcl::Window>&) include/vcl/vclptr.hxx:138:46 > #4 0x7f144bf56a2f in makeSvxPathControl filter/source/xsltdialog/xmlfiltersettingsdialog.cxx:1378:1 > #5 0x7f14d2060a04 in VclBuilder::makeObject(vcl::Window*, rtl::OString const&, rtl::OString const&, std::__debug::map<rtl::OString, rtl::OString, std::less<rtl::OString>, std::allocator<std::pair<rtl::OString const, rtl::OString> > >&) vcl/source/window/builder.cxx:1793:17 > #6 0x7f14d2078ddb in VclBuilder::insertObject(vcl::Window*, rtl::OString const&, rtl::OString const&, std::__debug::map<rtl::OString, rtl::OString, std::less<rtl::OString>, std::allocator<std::pair<rtl::OString const, rtl::OString> > >&, std::__debug::map<rtl::OString, rtl::OString, std::less<rtl::OString>, std::allocator<std::pair<rtl::OString const, rtl::OString> > >&, std::__debug::map<rtl::OString, rtl::OString, std::less<rtl::OString>, std::allocator<std::pair<rtl::OString const, rtl::OString> > >&) vcl/source/window/builder.cxx:1887:25 > #7 0x7f14d208790a in VclBuilder::handleObject(vcl::Window*, xmlreader::XmlReader&) vcl/source/window/builder.cxx:2856:37 > #8 0x7f14d20215bc in VclBuilder::handleChild(vcl::Window*, xmlreader::XmlReader&) vcl/source/window/builder.cxx:2114:33 > #9 0x7f14d2087bea in VclBuilder::handleObject(vcl::Window*, xmlreader::XmlReader&) vcl/source/window/builder.cxx:2859:17 > #10 0x7f14d20215bc in VclBuilder::handleChild(vcl::Window*, xmlreader::XmlReader&) vcl/source/window/builder.cxx:2114:33 > #11 0x7f14d2087bea in VclBuilder::handleObject(vcl::Window*, xmlreader::XmlReader&) vcl/source/window/builder.cxx:2859:17 > #12 0x7f14d20215bc in VclBuilder::handleChild(vcl::Window*, xmlreader::XmlReader&) vcl/source/window/builder.cxx:2114:33 > #13 0x7f14d200c59a in VclBuilder::VclBuilder(vcl::Window*, rtl::OUString const&, rtl::OUString const&, rtl::OString const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) vcl/source/window/builder.cxx:206:9 > #14 0x7f1492275862 in ScreenshotTest::dumpDialogToPath(rtl::OString const&) test/source/screenshot_test.cxx:177:24 The existing code apparently depended on any calls to getXSLTDialogResMgr in xmlfiltersettingsdialog.cxx only happening after pXSLTResMgr had been set up in the outer XMLFilterDialogComponent::execute in xmlfilterdialogcomponent.cxx. That is not true when each dialog is opened independently in the screenshot test, so instead just call CreateResMgr on demand wherever needed. Change-Id: I9f6dc7c66d4999137352a8d91665b954f4088085
Diffstat (limited to 'filter')
-rw-r--r--filter/source/xsltdialog/xmlfiltercommon.hxx5
-rw-r--r--filter/source/xsltdialog/xmlfilterdialogcomponent.cxx23
-rw-r--r--filter/source/xsltdialog/xmlfiltersettingsdialog.cxx37
3 files changed, 27 insertions, 38 deletions
diff --git a/filter/source/xsltdialog/xmlfiltercommon.hxx b/filter/source/xsltdialog/xmlfiltercommon.hxx
index 952cd1e9cc20..2f65dde7fc5f 100644
--- a/filter/source/xsltdialog/xmlfiltercommon.hxx
+++ b/filter/source/xsltdialog/xmlfiltercommon.hxx
@@ -84,11 +84,6 @@ extern std::vector< application_info_impl* >& getApplicationInfos();
extern OUString getApplicationUIName( const OUString& rServiceName );
extern const application_info_impl* getApplicationInfo( const OUString& rServiceName );
-extern ResMgr* getXSLTDialogResMgr();
-
-#define RESID(x) ResId(x, *getXSLTDialogResMgr())
-#define RESIDSTR(x) RESID(x).toString()
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/xsltdialog/xmlfilterdialogcomponent.cxx b/filter/source/xsltdialog/xmlfilterdialogcomponent.cxx
index 2baa87a5b6c4..7d4bb28f611d 100644
--- a/filter/source/xsltdialog/xmlfilterdialogcomponent.cxx
+++ b/filter/source/xsltdialog/xmlfilterdialogcomponent.cxx
@@ -34,7 +34,6 @@
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
-#include <tools/resmgr.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <rtl/instance.hxx>
@@ -110,17 +109,6 @@ private:
VclPtr<XMLFilterSettingsDialog> mpDialog;
};
-
-namespace
-{
- static ResMgr* pXSLTResMgr = nullptr;
-}
-
-ResMgr* getXSLTDialogResMgr()
-{
- return pXSLTResMgr;
-}
-
XMLFilterDialogComponent::XMLFilterDialogComponent( const css::uno::Reference< XComponentContext >& rxContext ) :
OComponentHelper( maMutex ),
mxContext( rxContext ),
@@ -258,12 +246,6 @@ void SAL_CALL XMLFilterDialogComponent::disposing()
::SolarMutexGuard aGuard;
mpDialog.disposeAndClear();
-
- if (pXSLTResMgr)
- {
- delete pXSLTResMgr;
- pXSLTResMgr = nullptr;
- }
}
@@ -308,11 +290,6 @@ sal_Int16 SAL_CALL XMLFilterDialogComponent::execute( ) throw(RuntimeException,
{
::SolarMutexGuard aGuard;
- if( nullptr == pXSLTResMgr )
- {
- pXSLTResMgr = ResMgr::CreateResMgr( "xsltdlg", Application::GetSettings().GetUILanguageTag() );
- }
-
if( nullptr == mpDialog )
{
Reference< XComponent > xComp( this );
diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
index ff1fac9117ec..02b30e958faa 100644
--- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
+++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
+#include <tools/resmgr.hxx>
#include <tools/urlobj.hxx>
#include <svtools/headbar.hxx>
#include <unotools/streamwrap.hxx>
@@ -31,6 +32,7 @@
#include <osl/file.hxx>
#include <o3tl/enumrange.hxx>
#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
#include <vcl/builderfactory.hxx>
#include <sfx2/filedlghelper.hxx>
#include "svtools/treelistentry.hxx"
@@ -38,6 +40,7 @@
#include <rtl/uri.hxx>
#include <algorithm>
+#include <memory>
#include "xmlfilterdialogstrings.hrc"
#include "xmlfiltersettingsdialog.hxx"
@@ -56,6 +59,19 @@ using namespace com::sun::star::util;
using ::rtl::Uri;
+namespace {
+
+std::unique_ptr<ResMgr> getXSLTDialogResMgr() {
+ return std::unique_ptr<ResMgr>(
+ ResMgr::CreateResMgr(
+ "xsltdlg", Application::GetSettings().GetUILanguageTag()));
+}
+
+}
+
+#define RESID(x) ResId(x, *getXSLTDialogResMgr().get())
+#define RESIDSTR(x) RESID(x).toString()
+
XMLFilterSettingsDialog::XMLFilterSettingsDialog(vcl::Window* pParent,
const css::uno::Reference<css::uno::XComponentContext>& rxContext,
Dialog::InitFlag eFlag)
@@ -230,7 +246,7 @@ void XMLFilterSettingsDialog::onNew()
aTempInfo.maDocumentService = "com.sun.star.text.TextDocument";
// execute XML Filter Dialog
- ScopedVclPtrInstance< XMLFilterTabDialog > aDlg( this, *getXSLTDialogResMgr(), mxContext, &aTempInfo );
+ ScopedVclPtrInstance< XMLFilterTabDialog > aDlg( this, *getXSLTDialogResMgr().get(), mxContext, &aTempInfo );
if ( aDlg->Execute() == RET_OK )
{
// insert the new filter
@@ -249,7 +265,7 @@ void XMLFilterSettingsDialog::onEdit()
filter_info_impl* pOldInfo = static_cast<filter_info_impl*>(pEntry->GetUserData());
// execute XML Filter Dialog
- ScopedVclPtrInstance< XMLFilterTabDialog > aDlg( this, *getXSLTDialogResMgr(), mxContext, pOldInfo );
+ ScopedVclPtrInstance< XMLFilterTabDialog > aDlg( this, *getXSLTDialogResMgr().get(), mxContext, pOldInfo );
if ( aDlg->Execute() == RET_OK )
{
filter_info_impl* pNewInfo = aDlg->getNewFilterInfo();
@@ -1206,28 +1222,29 @@ std::vector< application_info_impl* >& getApplicationInfos()
if( aInfos.empty() )
{
- ResId aResId1( STR_APPL_NAME_WRITER, *getXSLTDialogResMgr() );
+ auto resmgr = getXSLTDialogResMgr();
+ ResId aResId1( STR_APPL_NAME_WRITER, *resmgr.get() );
aInfos.push_back( new application_info_impl(
"com.sun.star.text.TextDocument",
aResId1,
"com.sun.star.comp.Writer.XMLImporter",
"com.sun.star.comp.Writer.XMLExporter" ) );
- ResId aResId2( STR_APPL_NAME_CALC, *getXSLTDialogResMgr() );
+ ResId aResId2( STR_APPL_NAME_CALC, *resmgr.get() );
aInfos.push_back( new application_info_impl(
"com.sun.star.sheet.SpreadsheetDocument",
aResId2,
"com.sun.star.comp.Calc.XMLImporter",
"com.sun.star.comp.Calc.XMLExporter" ) );
- ResId aResId3( STR_APPL_NAME_IMPRESS, *getXSLTDialogResMgr() );
+ ResId aResId3( STR_APPL_NAME_IMPRESS, *resmgr.get() );
aInfos.push_back( new application_info_impl(
"com.sun.star.presentation.PresentationDocument",
aResId3,
"com.sun.star.comp.Impress.XMLImporter",
"com.sun.star.comp.Impress.XMLExporter" ) );
- ResId aResId4( STR_APPL_NAME_DRAW, *getXSLTDialogResMgr() );
+ ResId aResId4( STR_APPL_NAME_DRAW, *resmgr.get() );
aInfos.push_back( new application_info_impl(
"com.sun.star.drawing.DrawingDocument",
aResId4,
@@ -1235,28 +1252,28 @@ std::vector< application_info_impl* >& getApplicationInfos()
"com.sun.star.comp.Draw.XMLExporter" ) );
// --- oasis file formats...
- ResId aResId5( STR_APPL_NAME_OASIS_WRITER, *getXSLTDialogResMgr() );
+ ResId aResId5( STR_APPL_NAME_OASIS_WRITER, *resmgr.get() );
aInfos.push_back( new application_info_impl(
"com.sun.star.text.TextDocument",
aResId5,
"com.sun.star.comp.Writer.XMLOasisImporter",
"com.sun.star.comp.Writer.XMLOasisExporter" ) );
- ResId aResId6( STR_APPL_NAME_OASIS_CALC, *getXSLTDialogResMgr() );
+ ResId aResId6( STR_APPL_NAME_OASIS_CALC, *resmgr.get() );
aInfos.push_back( new application_info_impl(
"com.sun.star.sheet.SpreadsheetDocument",
aResId6,
"com.sun.star.comp.Calc.XMLOasisImporter",
"com.sun.star.comp.Calc.XMLOasisExporter" ) );
- ResId aResId7( STR_APPL_NAME_OASIS_IMPRESS, *getXSLTDialogResMgr() );
+ ResId aResId7( STR_APPL_NAME_OASIS_IMPRESS, *resmgr.get() );
aInfos.push_back( new application_info_impl(
"com.sun.star.presentation.PresentationDocument",
aResId7,
"com.sun.star.comp.Impress.XMLOasisImporter",
"com.sun.star.comp.Impress.XMLOasisExporter" ) );
- ResId aResId8( STR_APPL_NAME_OASIS_DRAW, *getXSLTDialogResMgr() );
+ ResId aResId8( STR_APPL_NAME_OASIS_DRAW, *resmgr.get() );
aInfos.push_back( new application_info_impl(
"com.sun.star.drawing.DrawingDocument",
aResId8,