[Libreoffice-commits] core.git: 2 commits - cui/source include/com include/rtl include/svx svx/source
Stephan Bergmann
sbergman at redhat.com
Wed Jul 2 23:24:42 PDT 2014
cui/source/tabpages/tpbitmap.cxx | 6 +++--
cui/source/tabpages/tpcolor.cxx | 5 ++--
cui/source/tabpages/tpgradnt.cxx | 6 +++--
cui/source/tabpages/tphatch.cxx | 5 ++--
cui/source/tabpages/tplnedef.cxx | 2 -
cui/source/tabpages/tplneend.cxx | 5 +++-
include/com/sun/star/uno/Reference.h | 11 ++++++---
include/rtl/ref.hxx | 9 +++++--
include/svx/svdmodel.hxx | 12 +++++-----
include/svx/xtable.hxx | 42 +++++++++++++++++++++++++----------
svx/source/tbxctrls/fillctrl.cxx | 5 ++--
svx/source/unodraw/unoctabl.cxx | 4 ++-
svx/source/xoutdev/xtabcolr.cxx | 5 ++--
13 files changed, 78 insertions(+), 39 deletions(-)
New commits:
commit 7bbaa39102367a42ba416db6a578718fc4e7bdf1
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jul 3 08:23:39 2014 +0200
Catch invalid null pointer operations early
Change-Id: I324d5a6e84e0d2121d8e4612e074b44ed5127b11
diff --git a/include/com/sun/star/uno/Reference.h b/include/com/sun/star/uno/Reference.h
index ec45f44..cedd472 100644
--- a/include/com/sun/star/uno/Reference.h
+++ b/include/com/sun/star/uno/Reference.h
@@ -19,8 +19,11 @@
#ifndef INCLUDED_COM_SUN_STAR_UNO_REFERENCE_H
#define INCLUDED_COM_SUN_STAR_UNO_REFERENCE_H
-#include <rtl/alloc.h>
+#include <sal/config.h>
+
+#include <cassert>
+#include <rtl/alloc.h>
namespace com
{
@@ -395,8 +398,10 @@ public:
@return UNacquired interface pointer
*/
- inline interface_type * SAL_CALL operator -> () const
- { return castFromXInterface(_pInterface); }
+ inline interface_type * SAL_CALL operator -> () const {
+ assert(_pInterface != 0);
+ return castFromXInterface(_pInterface);
+ }
/** Gets interface pointer. This call does not acquire the interface.
diff --git a/include/rtl/ref.hxx b/include/rtl/ref.hxx
index cccbc01..3e90ed2 100644
--- a/include/rtl/ref.hxx
+++ b/include/rtl/ref.hxx
@@ -20,8 +20,11 @@
#ifndef INCLUDED_RTL_REF_HXX
#define INCLUDED_RTL_REF_HXX
+#include <sal/config.h>
+
+#include <cassert>
+
#include <sal/types.h>
-#include <osl/diagnose.h>
#include <osl/interlck.h>
namespace rtl
@@ -160,7 +163,7 @@ public:
*/
inline reference_type * SAL_CALL operator->() const
{
- OSL_PRECOND(m_pBody, "Reference::operator->() : null body");
+ assert(m_pBody != 0);
return m_pBody;
}
@@ -169,7 +172,7 @@ public:
*/
inline reference_type & SAL_CALL operator*() const
{
- OSL_PRECOND(m_pBody, "Reference::operator*() : null body");
+ assert(m_pBody != 0);
return *m_pBody;
}
commit f36e64d8cc4a2fce8d84ef464a482445a8b8540a
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jul 3 08:22:45 2014 +0200
Avoid null this pointers in member function calls
Change-Id: Iada6d8fcd261ddfb02b4dbc2f628ef0738c4ea01
diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx
index 4cab426..953993c 100644
--- a/cui/source/tabpages/tpbitmap.cxx
+++ b/cui/source/tabpages/tpbitmap.cxx
@@ -791,8 +791,10 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickLoadHdl_Impl)
aPathURL.removeFinalSlash();
// save table
- XBitmapListRef pBmpList = XPropertyList::CreatePropertyList(
- XBITMAP_LIST, aPathURL.GetMainURL( INetURLObject::NO_DECODE ), "" )->AsBitmapList();
+ XBitmapListRef pBmpList = XPropertyList::AsBitmapList(
+ XPropertyList::CreatePropertyList(
+ XBITMAP_LIST, aPathURL.GetMainURL(INetURLObject::NO_DECODE),
+ ""));
pBmpList->SetName( aURL.getName() );
if( pBmpList->Load() )
{
diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx
index add743b..52ead23 100644
--- a/cui/source/tabpages/tpcolor.cxx
+++ b/cui/source/tabpages/tpcolor.cxx
@@ -155,8 +155,9 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickLoadHdl_Impl)
if ( aDlg.Execute() == ERRCODE_NONE )
{
- XColorListRef pList = XPropertyList::CreatePropertyListFromURL(
- meType, aDlg.GetPath() )->AsColorList();
+ XColorListRef pList = XPropertyList::AsColorList(
+ XPropertyList::CreatePropertyListFromURL(
+ meType, aDlg.GetPath()));
if( pList->Load() )
{
// check whether the table may be deleted:
diff --git a/cui/source/tabpages/tpgradnt.cxx b/cui/source/tabpages/tpgradnt.cxx
index cbdefb3..96c48ff 100644
--- a/cui/source/tabpages/tpgradnt.cxx
+++ b/cui/source/tabpages/tpgradnt.cxx
@@ -644,8 +644,10 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickLoadHdl_Impl)
aPathURL.removeFinalSlash();
// save list
- XGradientListRef pGrdList = XPropertyList::CreatePropertyList(
- XGRADIENT_LIST, aPathURL.GetMainURL( INetURLObject::NO_DECODE ), "" )->AsGradientList();
+ XGradientListRef pGrdList = XPropertyList::AsGradientList(
+ XPropertyList::CreatePropertyList(
+ XGRADIENT_LIST,
+ aPathURL.GetMainURL(INetURLObject::NO_DECODE), ""));
pGrdList->SetName( aURL.getName() );
if ( pGrdList->Load() )
diff --git a/cui/source/tabpages/tphatch.cxx b/cui/source/tabpages/tphatch.cxx
index ae155b0..0cdff35 100644
--- a/cui/source/tabpages/tphatch.cxx
+++ b/cui/source/tabpages/tphatch.cxx
@@ -685,8 +685,9 @@ IMPL_LINK_NOARG(SvxHatchTabPage, ClickLoadHdl_Impl)
aPathURL.removeSegment();
aPathURL.removeFinalSlash();
- XHatchListRef pHatchList = XPropertyList::CreatePropertyList(
- XHATCH_LIST, aPathURL.GetMainURL( INetURLObject::NO_DECODE ), "" )->AsHatchList();
+ XHatchListRef pHatchList = XPropertyList::AsHatchList(
+ XPropertyList::CreatePropertyList(
+ XHATCH_LIST, aPathURL.GetMainURL( INetURLObject::NO_DECODE ), "" ));
pHatchList->SetName( aURL.getName() );
if( pHatchList->Load() )
{
diff --git a/cui/source/tabpages/tplnedef.cxx b/cui/source/tabpages/tplnedef.cxx
index 7dcca4b..b2ddb14 100644
--- a/cui/source/tabpages/tplnedef.cxx
+++ b/cui/source/tabpages/tplnedef.cxx
@@ -749,7 +749,7 @@ IMPL_LINK_NOARG(SvxLineDefTabPage, ClickLoadHdl_Impl)
aPathURL.removeSegment();
aPathURL.removeFinalSlash();
- XDashListRef pDshLst = XPropertyList::CreatePropertyList( XDASH_LIST, aPathURL.GetMainURL( INetURLObject::NO_DECODE ), "" )->AsDashList();
+ XDashListRef pDshLst = XPropertyList::AsDashList(XPropertyList::CreatePropertyList( XDASH_LIST, aPathURL.GetMainURL( INetURLObject::NO_DECODE ), "" ));
pDshLst->SetName( aURL.getName() );
if( pDshLst->Load() )
diff --git a/cui/source/tabpages/tplneend.cxx b/cui/source/tabpages/tplneend.cxx
index 6cbcce8..c0264a7 100644
--- a/cui/source/tabpages/tplneend.cxx
+++ b/cui/source/tabpages/tplneend.cxx
@@ -570,7 +570,10 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickLoadHdl_Impl)
aPathURL.removeSegment();
aPathURL.removeFinalSlash();
- XLineEndListRef pLeList = XPropertyList::CreatePropertyList(XLINE_END_LIST, aPathURL.GetMainURL( INetURLObject::NO_DECODE ), "" )->AsLineEndList();
+ XLineEndListRef pLeList = XPropertyList::AsLineEndList(
+ XPropertyList::CreatePropertyList(
+ XLINE_END_LIST,
+ aPathURL.GetMainURL(INetURLObject::NO_DECODE), ""));
pLeList->SetName( aURL.getName() );
if( pLeList->Load() )
{
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index 350ad96..5be7bcb 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -597,12 +597,12 @@ public:
void SetPropertyList( XPropertyListRef p ) { maProperties[ p->Type() ] = p; }
// friendlier helpers
- XDashListRef GetDashList() const { return GetPropertyList( XDASH_LIST )->AsDashList(); }
- XHatchListRef GetHatchList() const { return GetPropertyList( XHATCH_LIST )->AsHatchList(); }
- XColorListRef GetColorList() const { return GetPropertyList( XCOLOR_LIST )->AsColorList(); }
- XBitmapListRef GetBitmapList() const { return GetPropertyList( XBITMAP_LIST )->AsBitmapList(); }
- XLineEndListRef GetLineEndList() const { return GetPropertyList( XLINE_END_LIST )->AsLineEndList(); }
- XGradientListRef GetGradientList() const { return GetPropertyList( XGRADIENT_LIST )->AsGradientList(); }
+ XDashListRef GetDashList() const { return XPropertyList::AsDashList(GetPropertyList( XDASH_LIST )); }
+ XHatchListRef GetHatchList() const { return XPropertyList::AsHatchList(GetPropertyList( XHATCH_LIST )); }
+ XColorListRef GetColorList() const { return XPropertyList::AsColorList(GetPropertyList( XCOLOR_LIST )); }
+ XBitmapListRef GetBitmapList() const { return XPropertyList::AsBitmapList(GetPropertyList( XBITMAP_LIST )); }
+ XLineEndListRef GetLineEndList() const { return XPropertyList::AsLineEndList(GetPropertyList( XLINE_END_LIST )); }
+ XGradientListRef GetGradientList() const { return XPropertyList::AsGradientList(GetPropertyList( XGRADIENT_LIST )); }
// The DrawingEngine only references the StyleSheetPool, whoever
// made it needs to delete it.
diff --git a/include/svx/xtable.hxx b/include/svx/xtable.hxx
index d86b5f4..a658596 100644
--- a/include/svx/xtable.hxx
+++ b/include/svx/xtable.hxx
@@ -266,12 +266,18 @@ public:
const OUString & rUrl);
// helper accessors
- inline XDashListRef AsDashList();
- inline XHatchListRef AsHatchList();
- inline XColorListRef AsColorList();
- inline XBitmapListRef AsBitmapList();
- inline XLineEndListRef AsLineEndList();
- inline XGradientListRef AsGradientList();
+ static inline XDashListRef AsDashList(
+ rtl::Reference<XPropertyList> const & plist);
+ static inline XHatchListRef AsHatchList(
+ rtl::Reference<XPropertyList> const & plist);
+ static inline XColorListRef AsColorList(
+ rtl::Reference<XPropertyList> const & plist);
+ static inline XBitmapListRef AsBitmapList(
+ rtl::Reference<XPropertyList> const & plist);
+ static inline XLineEndListRef AsLineEndList(
+ rtl::Reference<XPropertyList> const & plist);
+ static inline XGradientListRef AsGradientList(
+ rtl::Reference<XPropertyList> const & plist);
};
@@ -429,12 +435,24 @@ public:
// FIXME: could add type checking too ...
-inline XDashListRef XPropertyList::AsDashList() { return XDashListRef( static_cast<XDashList *> (this) ); }
-inline XHatchListRef XPropertyList::AsHatchList() { return XHatchListRef( static_cast<XHatchList *> (this) ); }
-inline XColorListRef XPropertyList::AsColorList() { return XColorListRef( static_cast<XColorList *> (this) ); }
-inline XBitmapListRef XPropertyList::AsBitmapList() { return XBitmapListRef( static_cast<XBitmapList *> (this) ); }
-inline XLineEndListRef XPropertyList::AsLineEndList() { return XLineEndListRef( static_cast<XLineEndList *> (this) ); }
-inline XGradientListRef XPropertyList::AsGradientList() { return XGradientListRef( static_cast<XGradientList *> (this) ); }
+inline XDashListRef XPropertyList::AsDashList(
+ rtl::Reference<XPropertyList> const & plist)
+{ return XDashListRef( static_cast<XDashList *> (plist.get()) ); }
+inline XHatchListRef XPropertyList::AsHatchList(
+ rtl::Reference<XPropertyList> const & plist)
+{ return XHatchListRef( static_cast<XHatchList *> (plist.get()) ); }
+inline XColorListRef XPropertyList::AsColorList(
+ rtl::Reference<XPropertyList> const & plist)
+{ return XColorListRef( static_cast<XColorList *> (plist.get()) ); }
+inline XBitmapListRef XPropertyList::AsBitmapList(
+ rtl::Reference<XPropertyList> const & plist)
+{ return XBitmapListRef( static_cast<XBitmapList *> (plist.get()) ); }
+inline XLineEndListRef XPropertyList::AsLineEndList(
+ rtl::Reference<XPropertyList> const & plist)
+{ return XLineEndListRef( static_cast<XLineEndList *> (plist.get()) ); }
+inline XGradientListRef XPropertyList::AsGradientList(
+ rtl::Reference<XPropertyList> const & plist)
+{ return XGradientListRef( static_cast<XGradientList *> (plist.get()) ); }
#endif // INCLUDED_SVX_XTABLE_HXX
diff --git a/svx/source/tbxctrls/fillctrl.cxx b/svx/source/tbxctrls/fillctrl.cxx
index 097d475..fb0b930 100644
--- a/svx/source/tbxctrls/fillctrl.cxx
+++ b/svx/source/tbxctrls/fillctrl.cxx
@@ -410,8 +410,9 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
boost::scoped_ptr<XBitmapEntry> pEntry(new XBitmapEntry(mpBitmapItem->GetGraphicObject(), aTmpStr));
XBitmapListRef xBitmapList =
- XPropertyList::CreatePropertyList(XBITMAP_LIST,
- OUString("TmpList"), ""/*TODO?*/)->AsBitmapList();
+ XPropertyList::AsBitmapList(
+ XPropertyList::CreatePropertyList(
+ XBITMAP_LIST, "TmpList", ""/*TODO?*/));
xBitmapList->Insert( pEntry.get() );
xBitmapList->SetDirty( false );
mpFillAttrLB->Fill( xBitmapList );
diff --git a/svx/source/unodraw/unoctabl.cxx b/svx/source/unodraw/unoctabl.cxx
index 759435c..5a4136d 100644
--- a/svx/source/unodraw/unoctabl.cxx
+++ b/svx/source/unodraw/unoctabl.cxx
@@ -64,7 +64,9 @@ public:
SvxUnoColorTable::SvxUnoColorTable()
{
- pList = XPropertyList::CreatePropertyList( XCOLOR_LIST, SvtPathOptions().GetPalettePath(), "" )->AsColorList();
+ pList = XPropertyList::AsColorList(
+ XPropertyList::CreatePropertyList(
+ XCOLOR_LIST, SvtPathOptions().GetPalettePath(), ""));
}
sal_Bool SAL_CALL SvxUnoColorTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException, std::exception)
diff --git a/svx/source/xoutdev/xtabcolr.cxx b/svx/source/xoutdev/xtabcolr.cxx
index d70a4fb..85c3b4f 100644
--- a/svx/source/xoutdev/xtabcolr.cxx
+++ b/svx/source/xoutdev/xtabcolr.cxx
@@ -29,8 +29,9 @@ using namespace com::sun::star;
XColorListRef XColorList::CreateStdColorList()
{
- return XPropertyList::CreatePropertyList(
- XCOLOR_LIST, SvtPathOptions().GetPalettePath(), "" )->AsColorList();
+ return XPropertyList::AsColorList(
+ XPropertyList::CreatePropertyList(
+ XCOLOR_LIST, SvtPathOptions().GetPalettePath(), ""));
}
XColorListRef XColorList::GetStdColorList()
More information about the Libreoffice-commits
mailing list