[Libreoffice-commits] core.git: 3 commits - include/sfx2 include/tools sfx2/source
Noel Grandin
noel at peralex.com
Mon Jul 14 04:33:11 PDT 2014
include/sfx2/fcontnr.hxx | 11 +++++------
include/tools/ref.hxx | 27 +++++++++++++++++----------
sfx2/source/inc/objshimp.hxx | 2 +-
3 files changed, 23 insertions(+), 17 deletions(-)
New commits:
commit 48528e00629e746a5e091a70644b9456e5037b7f
Author: Noel Grandin <noel at peralex.com>
Date: Thu Jul 10 15:44:28 2014 +0200
add some comments to include/tools/ref.hxx
Change-Id: Ic38d7f5f816f2a91bfb468c0b7fb241b084a0c44
diff --git a/include/tools/ref.hxx b/include/tools/ref.hxx
index cc52da4..6a8a01d 100644
--- a/include/tools/ref.hxx
+++ b/include/tools/ref.hxx
@@ -28,6 +28,7 @@
namespace tools {
+/** T must be a class that extends SvRefBase */
template<typename T> class SvRef {
public:
SvRef(): pObj(0) {}
@@ -142,6 +143,7 @@ public:
};
+/** Classes that want to be referenced-counted via SvRef<T>, should extend this base class */
class TOOLS_DLLPUBLIC SvRefBase
{
static const sal_uIntPtr SV_NO_DELETE_REFCOUNT = 0x80000000;
@@ -184,27 +186,36 @@ public:
{ return nRefCount; }
};
+/** We only have one weak reference in LO, in include/sfx2/frame.hxx, class SfxFrameWeak.
+ This acts as a intermediary between SfxFrameWeak and SfxFrame_Impl.
+*/
class SvCompatWeakHdl : public SvRefBase
{
friend class SvCompatWeakBase;
void* _pObj;
+
SvCompatWeakHdl( void* pObj ) : _pObj( pObj ) {}
public:
- void ResetWeakBase( ) { _pObj = 0; }
+ void ResetWeakBase( ) { _pObj = 0; }
void* GetObj() { return _pObj; }
};
+/** We only have one place that extends this, in sfx2/source/view/impframe.hxx, class SfxFrame_Impl,
+ its function is to notify the SvCompatWeakHdl when an SfxFrame_Impl object is deleted.
+*/
class SvCompatWeakBase
{
tools::SvRef<SvCompatWeakHdl> _xHdl;
public:
- SvCompatWeakHdl* GetHdl() { return _xHdl; }
-
- // does not use initializer due to compiler warnings
+ // Does not use initializer due to compiler warnings,
+ // because the lifetime of the _xHdl object can exceed the lifetime of this class.
SvCompatWeakBase( void* pObj ) { _xHdl = new SvCompatWeakHdl( pObj ); }
+
~SvCompatWeakBase() { _xHdl->ResetWeakBase(); }
+
+ SvCompatWeakHdl* GetHdl() { return _xHdl; }
};
#define SV_DECL_COMPAT_WEAK( ClassName ) \
commit 4ed943a24b79d2e4da30bdb282143327a8bfffd8
Author: Noel Grandin <noel at peralex.com>
Date: Thu Jul 10 15:32:43 2014 +0200
inline SvCompatWeakHdlRef typedef
.. only used in 2 places in the same file
Change-Id: I5dc1dc77c3841bf86134f6a48597f8c1e71b2b3f
diff --git a/include/tools/ref.hxx b/include/tools/ref.hxx
index c2365f1..cc52da4 100644
--- a/include/tools/ref.hxx
+++ b/include/tools/ref.hxx
@@ -195,11 +195,9 @@ public:
void* GetObj() { return _pObj; }
};
-typedef tools::SvRef<SvCompatWeakHdl> SvCompatWeakHdlRef;
-
class SvCompatWeakBase
{
- SvCompatWeakHdlRef _xHdl;
+ tools::SvRef<SvCompatWeakHdl> _xHdl;
public:
SvCompatWeakHdl* GetHdl() { return _xHdl; }
@@ -212,7 +210,7 @@ public:
#define SV_DECL_COMPAT_WEAK( ClassName ) \
class ClassName##Weak \
{ \
- SvCompatWeakHdlRef _xHdl; \
+ tools::SvRef<SvCompatWeakHdl> _xHdl; \
public: \
inline ClassName##Weak( ) {} \
inline ClassName##Weak( ClassName* pObj ) { \
commit 6d2178b8c82ac7d2ac054e55b4221033acfab3d8
Author: Noel Grandin <noel at peralex.com>
Date: Thu Jul 10 15:24:02 2014 +0200
inline tools::SvRefBaseRef typedef
..it is only used in two places
Change-Id: If333936b26592ed44d3525f2eb3c21aafde7dddc
diff --git a/include/sfx2/fcontnr.hxx b/include/sfx2/fcontnr.hxx
index 8c3881a..96ebdcd 100644
--- a/include/sfx2/fcontnr.hxx
+++ b/include/sfx2/fcontnr.hxx
@@ -47,16 +47,15 @@ typedef sal_uInt16 SfxFilterContainerFlags;
class SfxRefItem : public SfxPoolItem
{
- SvRefBaseRef aRef;
+ tools::SvRef<SvRefBase> maRef;
public:
+ SfxRefItem( sal_uInt16 nWhichId, const tools::SvRef<SvRefBase>& rValue ) : SfxPoolItem( nWhichId )
+ { maRef = rValue; }
virtual SfxPoolItem* Clone( SfxItemPool* = 0 ) const SAL_OVERRIDE
{ return new SfxRefItem( *this ); }
virtual bool operator==( const SfxPoolItem& rL) const SAL_OVERRIDE
- { return ((SfxRefItem&)rL).aRef == aRef; }
- SfxRefItem( sal_uInt16 nWhichId, const SvRefBaseRef& rValue ) : SfxPoolItem( nWhichId )
- { aRef = rValue; }
- const SvRefBaseRef& GetValue() const { return aRef; }
-
+ { return ((SfxRefItem&)rL).maRef == maRef; }
+ const tools::SvRef<SvRefBase>& GetValue() const { return maRef; }
};
class SfxFrameWindow
diff --git a/include/tools/ref.hxx b/include/tools/ref.hxx
index 4d9bc86..c2365f1 100644
--- a/include/tools/ref.hxx
+++ b/include/tools/ref.hxx
@@ -184,8 +184,6 @@ public:
{ return nRefCount; }
};
-typedef tools::SvRef<SvRefBase> SvRefBaseRef;
-
class SvCompatWeakHdl : public SvRefBase
{
friend class SvCompatWeakBase;
diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx
index 72cbd96..a32e4f3 100644
--- a/sfx2/source/inc/objshimp.hxx
+++ b/sfx2/source/inc/objshimp.hxx
@@ -108,7 +108,7 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess
SfxModule* pModule;
SfxObjectShellFlags eFlags;
bool bReadOnlyUI;
- SvRefBaseRef xHeaderAttributes;
+ tools::SvRef<SvRefBase> xHeaderAttributes;
::rtl::Reference< SfxBaseModel >
pBaseModel;
sal_uInt16 nStyleFilter;
More information about the Libreoffice-commits
mailing list