summaryrefslogtreecommitdiff
path: root/include/tools/ref.hxx
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-07-10 15:44:28 +0200
committerNoel Grandin <noel@peralex.com>2014-07-14 13:31:59 +0200
commit48528e00629e746a5e091a70644b9456e5037b7f (patch)
tree548563a944077ca0eb07a322446f7a97a6c22179 /include/tools/ref.hxx
parent4ed943a24b79d2e4da30bdb282143327a8bfffd8 (diff)
add some comments to include/tools/ref.hxx
Change-Id: Ic38d7f5f816f2a91bfb468c0b7fb241b084a0c44
Diffstat (limited to 'include/tools/ref.hxx')
-rw-r--r--include/tools/ref.hxx19
1 files changed, 15 insertions, 4 deletions
diff --git a/include/tools/ref.hxx b/include/tools/ref.hxx
index cc52da44d297..6a8a01d237f3 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 ) \