formula/source/ui/dlg/FormulaHelper.cxx | 4 +--- include/formula/IFunctionDescription.hxx | 5 +++-- remotebridges/source/unourl_resolver/unourl_resolver.cxx | 2 +- reportdesign/source/core/api/ReportDefinition.cxx | 4 ++-- reportdesign/source/core/sdr/UndoEnv.cxx | 4 ++-- reportdesign/source/core/sdr/formatnormalizer.hxx | 2 +- reportdesign/source/filter/xml/dbloader2.hxx | 2 +- reportdesign/source/filter/xml/xmlAutoStyle.hxx | 2 +- reportdesign/source/filter/xml/xmlExport.cxx | 2 +- reportdesign/source/ui/dlg/AddField.cxx | 2 +- reportdesign/source/ui/dlg/CondFormat.cxx | 2 +- reportdesign/source/ui/dlg/GroupExchange.hxx | 2 +- reportdesign/source/ui/dlg/GroupsSorting.cxx | 2 +- reportdesign/source/ui/report/DesignView.cxx | 2 +- reportdesign/source/ui/report/ReportControllerObserver.cxx | 2 +- reportdesign/source/ui/report/ViewsWindow.cxx | 4 ++-- sc/inc/funcdesc.hxx | 10 ++++++---- sc/source/core/data/funcdesc.cxx | 7 ++++--- 18 files changed, 31 insertions(+), 29 deletions(-)
New commits: commit 7c3abee29c742593206b755b20a718c46f0780fa Author: Caolán McNamara <[email protected]> Date: Thu Jun 11 16:52:09 2015 +0100 Resolves: tdf#89643 report builder function wizard segfaults regression from commit 3d6521280929ecacc53b7c358d29d0b5d31b3462 CommitDate: Thu Jul 31 22:14:25 2014 +0200 fix memory leak around function descriptions Found by Lsan. There are two implementations of getCategory, one (sc) returns a new one each time (hence the leak fix) and the other (reportdesign) returns a pointer to one that belongs to the manger (hence the crash). The code in formula really looks to me to expect that the getCategory return a pointer that "someone else" needs to look after, i.e. the reportdesign variant is the more correct so revert 3d6521280929ecacc53b7c358d29d0b5d31b3462 and to fix the leak make the sc own the ScFunctionCategories and just cache them like the reportdesign one does Change-Id: Ifd986301a54b4d20449e864697655cd973e0c4df diff --git a/formula/source/ui/dlg/FormulaHelper.cxx b/formula/source/ui/dlg/FormulaHelper.cxx index dc15145..7570ef6 100644 --- a/formula/source/ui/dlg/FormulaHelper.cxx +++ b/formula/source/ui/dlg/FormulaHelper.cxx @@ -23,8 +23,6 @@ #include <unotools/charclass.hxx> #include <unotools/syslocale.hxx> -#include <boost/scoped_ptr.hpp> - namespace formula { @@ -95,7 +93,7 @@ bool FormulaHelper::GetNextFunc( const OUString& rFormula, const sal_uInt32 nCategoryCount = m_pFunctionManager->getCount(); for(sal_uInt32 j= 0; j < nCategoryCount && !*ppFDesc; ++j) { - boost::scoped_ptr<const IFunctionCategory> pCategory(m_pFunctionManager->getCategory(j)); + const IFunctionCategory* pCategory = m_pFunctionManager->getCategory(j); const sal_uInt32 nCount = pCategory->getCount(); for(sal_uInt32 i = 0 ; i < nCount; ++i) { diff --git a/include/formula/IFunctionDescription.hxx b/include/formula/IFunctionDescription.hxx index 1b37d51..85f42aa 100644 --- a/include/formula/IFunctionDescription.hxx +++ b/include/formula/IFunctionDescription.hxx @@ -60,7 +60,7 @@ namespace formula ~IFunctionManager() {} }; - class IFunctionCategory + class SAL_NO_VTABLE IFunctionCategory { public: IFunctionCategory(){} @@ -70,7 +70,8 @@ namespace formula virtual sal_uInt32 getNumber() const = 0; virtual OUString getName() const = 0; - virtual ~IFunctionCategory() {} + protected: + ~IFunctionCategory() {} }; class SAL_NO_VTABLE IFunctionDescription diff --git a/sc/inc/funcdesc.hxx b/sc/inc/funcdesc.hxx index e746462..43e4101 100644 --- a/sc/inc/funcdesc.hxx +++ b/sc/inc/funcdesc.hxx @@ -27,6 +27,7 @@ #include <formula/IFunctionDescription.hxx> #include <sal/types.h> #include <rtl/ustring.hxx> +#include <map> #define MAX_FUNCCAT 12 /* maximum number of categories for functions */ #define LRU_MAX 10 /* maximal number of last recently used functions */ @@ -361,7 +362,7 @@ public: /** Returns a category. - Creates an IFunctionCategory object from a category specified by nPos. + Returns an IFunctionCategory object for a category specified by nPos. @param nPos the index of the category, note that 0 maps to the first category not the cumulative ('All') category. @@ -399,9 +400,10 @@ public: private: ScFunctionList* pFuncList; /**< list of all calc functions */ - ::std::vector<const ScFuncDesc*>* aCatLists[MAX_FUNCCAT]; /**< array of all categories, 0 is the cumulative ('All') category */ - mutable ::std::vector<const ScFuncDesc*>::iterator pCurCatListIter; /**< position in current category */ - mutable ::std::vector<const ScFuncDesc*>::iterator pCurCatListEnd; /**< end of current category */ + std::vector<const ScFuncDesc*>* aCatLists[MAX_FUNCCAT]; /**< array of all categories, 0 is the cumulative ('All') category */ + mutable std::map< sal_uInt32, std::shared_ptr<ScFunctionCategory> > m_aCategories; /**< map of category pos to IFunctionCategory */ + mutable std::vector<const ScFuncDesc*>::iterator pCurCatListIter; /**< position in current category */ + mutable std::vector<const ScFuncDesc*>::iterator pCurCatListEnd; /**< end of current category */ }; #endif // INCLUDED_SC_INC_FUNCDESC_HXX diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx index 9dd713d..d9d0266 100644 --- a/sc/source/core/data/funcdesc.cxx +++ b/sc/source/core/data/funcdesc.cxx @@ -752,12 +752,13 @@ sal_uInt32 ScFunctionMgr::getCount() const const formula::IFunctionCategory* ScFunctionMgr::getCategory(sal_uInt32 nCategory) const { - formula::IFunctionCategory* pRet = NULL; if ( nCategory < (MAX_FUNCCAT-1) ) { - pRet = new ScFunctionCategory(const_cast<ScFunctionMgr*>(this),aCatLists[nCategory+1],nCategory); // aCatLists[0] is "all" + if (m_aCategories.find(nCategory) == m_aCategories.end()) + m_aCategories[nCategory].reset(new ScFunctionCategory(const_cast<ScFunctionMgr*>(this),aCatLists[nCategory+1],nCategory)); // aCatLists[0] is "all" + return m_aCategories[nCategory].get(); } - return pRet; + return NULL; } const formula::IFunctionDescription* ScFunctionMgr::getFunctionByName(const OUString& _sFunctionName) const commit 19053e62d1f8e23c82d03c14228e127792ef46ce Author: Caolán McNamara <[email protected]> Date: Thu Jun 11 17:09:41 2015 +0100 cppcheck: noExplicitConstructor Change-Id: I2d629c48b6526fa5f37174921c068e1201a897ef diff --git a/remotebridges/source/unourl_resolver/unourl_resolver.cxx b/remotebridges/source/unourl_resolver/unourl_resolver.cxx index 9468392..a656ed1 100644 --- a/remotebridges/source/unourl_resolver/unourl_resolver.cxx +++ b/remotebridges/source/unourl_resolver/unourl_resolver.cxx @@ -65,7 +65,7 @@ class ResolverImpl : public WeakImplHelper2< XServiceInfo, XUnoUrlResolver > Reference< XComponentContext > _xCtx; public: - ResolverImpl( const Reference< XComponentContext > & xSMgr ); + explicit ResolverImpl( const Reference< XComponentContext > & xSMgr ); virtual ~ResolverImpl(); // XServiceInfo diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index 42b0baf..27adf77 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -528,7 +528,7 @@ struct OReportDefinitionImpl bool m_bEscapeProcessing; bool m_bSetModifiedEnabled; - OReportDefinitionImpl(::osl::Mutex& _aMutex) + explicit OReportDefinitionImpl(::osl::Mutex& _aMutex) :m_aStorageChangeListeners(_aMutex) ,m_aCloseListener(_aMutex) ,m_aModifyListeners(_aMutex) @@ -2298,7 +2298,7 @@ class OStylesHelper: protected: virtual ~OStylesHelper(){} public: - OStylesHelper(const uno::Type& rType = cppu::UnoType<container::XElementAccess>::get()); + explicit OStylesHelper(const uno::Type& rType = cppu::UnoType<container::XElementAccess>::get()); // XNameContainer virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::ElementExistException,lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE; diff --git a/reportdesign/source/core/sdr/UndoEnv.cxx b/reportdesign/source/core/sdr/UndoEnv.cxx index bb9287f..fc49b37 100644 --- a/reportdesign/source/core/sdr/UndoEnv.cxx +++ b/reportdesign/source/core/sdr/UndoEnv.cxx @@ -66,7 +66,7 @@ struct PropertyInfo { bool bIsReadonlyOrTransient; - PropertyInfo( const bool i_bIsTransientOrReadOnly ) + explicit PropertyInfo( const bool i_bIsTransientOrReadOnly ) :bIsReadonlyOrTransient( i_bIsTransientOrReadOnly ) { } @@ -104,7 +104,7 @@ public: bool m_bReadOnly; bool m_bIsUndo; - OXUndoEnvironmentImpl(OReportModel& _rModel); + explicit OXUndoEnvironmentImpl(OReportModel& _rModel); }; OXUndoEnvironmentImpl::OXUndoEnvironmentImpl(OReportModel& _rModel) : m_rModel(_rModel) diff --git a/reportdesign/source/core/sdr/formatnormalizer.hxx b/reportdesign/source/core/sdr/formatnormalizer.hxx index d85ce59..d4da500 100644 --- a/reportdesign/source/core/sdr/formatnormalizer.hxx +++ b/reportdesign/source/core/sdr/formatnormalizer.hxx @@ -60,7 +60,7 @@ namespace rptui bool m_bFieldListDirty; public: - FormatNormalizer( const OReportModel& _rModel ); + explicit FormatNormalizer( const OReportModel& _rModel ); ~FormatNormalizer(); void notifyPropertyChange( const ::com::sun::star::beans::PropertyChangeEvent& _rEvent ); diff --git a/reportdesign/source/filter/xml/dbloader2.hxx b/reportdesign/source/filter/xml/dbloader2.hxx index 687e27d..edd8387 100644 --- a/reportdesign/source/filter/xml/dbloader2.hxx +++ b/reportdesign/source/filter/xml/dbloader2.hxx @@ -68,7 +68,7 @@ namespace rptxml { ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; public: - ORptTypeDetection(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); + explicit ORptTypeDetection(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); // XServiceInfo OUString SAL_CALL getImplementationName() throw(std::exception ) SAL_OVERRIDE; diff --git a/reportdesign/source/filter/xml/xmlAutoStyle.hxx b/reportdesign/source/filter/xml/xmlAutoStyle.hxx index 2fe7f67..abcfdac 100644 --- a/reportdesign/source/filter/xml/xmlAutoStyle.hxx +++ b/reportdesign/source/filter/xml/xmlAutoStyle.hxx @@ -43,7 +43,7 @@ namespace rptxml OXMLAutoStylePoolP(const OXMLAutoStylePoolP&) SAL_DELETED_FUNCTION; void operator =(const OXMLAutoStylePoolP&) SAL_DELETED_FUNCTION; public: - OXMLAutoStylePoolP(ORptExport& rXMLExport); + explicit OXMLAutoStylePoolP(ORptExport& rXMLExport); virtual ~OXMLAutoStylePoolP(); }; diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx index bf7594e9..5f6e9e7 100644 --- a/reportdesign/source/filter/xml/xmlExport.cxx +++ b/reportdesign/source/filter/xml/xmlExport.cxx @@ -164,7 +164,7 @@ namespace rptxml class OSpecialHandleXMLExportPropertyMapper : public SvXMLExportPropertyMapper { public: - OSpecialHandleXMLExportPropertyMapper(const rtl::Reference< XMLPropertySetMapper >& rMapper) : SvXMLExportPropertyMapper(rMapper ) + explicit OSpecialHandleXMLExportPropertyMapper(const rtl::Reference< XMLPropertySetMapper >& rMapper) : SvXMLExportPropertyMapper(rMapper ) { } /** this method is called for every item that has the diff --git a/reportdesign/source/ui/dlg/AddField.cxx b/reportdesign/source/ui/dlg/AddField.cxx index 657479a..6020abb 100644 --- a/reportdesign/source/ui/dlg/AddField.cxx +++ b/reportdesign/source/ui/dlg/AddField.cxx @@ -65,7 +65,7 @@ class OAddFieldWindowListBox: public SvTreeListBox VclPtr<OAddFieldWindow> m_pTabWin; public: - OAddFieldWindowListBox( OAddFieldWindow* _pParent ); + explicit OAddFieldWindowListBox( OAddFieldWindow* _pParent ); virtual ~OAddFieldWindowListBox(); virtual void dispose() SAL_OVERRIDE; diff --git a/reportdesign/source/ui/dlg/CondFormat.cxx b/reportdesign/source/ui/dlg/CondFormat.cxx index 24e2bce..1f9efb7 100644 --- a/reportdesign/source/ui/dlg/CondFormat.cxx +++ b/reportdesign/source/ui/dlg/CondFormat.cxx @@ -69,7 +69,7 @@ namespace rptui vcl::Window& m_rWindow; public: - UpdateLocker( vcl::Window& _rWindow ) + explicit UpdateLocker( vcl::Window& _rWindow ) :m_rWindow( _rWindow ) { _rWindow.SetUpdateMode( false ); diff --git a/reportdesign/source/ui/dlg/GroupExchange.hxx b/reportdesign/source/ui/dlg/GroupExchange.hxx index a057067..39d5758 100644 --- a/reportdesign/source/ui/dlg/GroupExchange.hxx +++ b/reportdesign/source/ui/dlg/GroupExchange.hxx @@ -32,7 +32,7 @@ namespace rptui { ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> m_aGroupRow; public: - OGroupExchange(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& _aGroupRow); + explicit OGroupExchange(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& _aGroupRow); static SotClipboardFormatId getReportGroupId(); protected: diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx b/reportdesign/source/ui/dlg/GroupsSorting.cxx index 5eb0456..473cb45 100644 --- a/reportdesign/source/ui/dlg/GroupsSorting.cxx +++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx @@ -85,7 +85,7 @@ class OFieldExpressionControlContainerListener : public ::cppu::WeakImplHelper1< { VclPtr<OFieldExpressionControl> mpParent; public: - OFieldExpressionControlContainerListener(OFieldExpressionControl* pParent) : mpParent(pParent) {} + explicit OFieldExpressionControlContainerListener(OFieldExpressionControl* pParent) : mpParent(pParent) {} // XEventListener virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; diff --git a/reportdesign/source/ui/report/DesignView.cxx b/reportdesign/source/ui/report/DesignView.cxx index 9d9f0ad..59144e4 100644 --- a/reportdesign/source/ui/report/DesignView.cxx +++ b/reportdesign/source/ui/report/DesignView.cxx @@ -61,7 +61,7 @@ class OTaskWindow : public vcl::Window { VclPtr<PropBrw> m_pPropWin; public: - OTaskWindow(vcl::Window* _pParent) : Window(_pParent),m_pPropWin(NULL){} + explicit OTaskWindow(vcl::Window* _pParent) : Window(_pParent),m_pPropWin(NULL){} virtual ~OTaskWindow() { disposeOnce(); } virtual void dispose() SAL_OVERRIDE { m_pPropWin.clear(); vcl::Window::dispose(); } diff --git a/reportdesign/source/ui/report/ReportControllerObserver.cxx b/reportdesign/source/ui/report/ReportControllerObserver.cxx index 3dd5b00..b93f49f 100644 --- a/reportdesign/source/ui/report/ReportControllerObserver.cxx +++ b/reportdesign/source/ui/report/ReportControllerObserver.cxx @@ -57,7 +57,7 @@ public: oslInterlockedCount m_nLocks; bool m_bReadOnly; - OXReportControllerObserverImpl(const OReportController& _rController); + explicit OXReportControllerObserverImpl(const OReportController& _rController); ~OXReportControllerObserverImpl(); }; diff --git a/reportdesign/source/ui/report/ViewsWindow.cxx b/reportdesign/source/ui/report/ViewsWindow.cxx index 02552e6..d4dba4f 100644 --- a/reportdesign/source/ui/report/ViewsWindow.cxx +++ b/reportdesign/source/ui/report/ViewsWindow.cxx @@ -958,13 +958,13 @@ namespace bool m_bCopy; public: - ApplySectionViewAction(bool _bCopy) + explicit ApplySectionViewAction(bool _bCopy) : m_eAction(eEndDragObj) , m_bCopy(_bCopy) { } - ApplySectionViewAction(SectionViewAction _eAction = eEndAction) + explicit ApplySectionViewAction(SectionViewAction _eAction = eEndAction) : m_eAction(_eAction) , m_bCopy(false) {
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
