+void wxObject::AllocExclusive()
+{
+ if ( !m_refData )
+ {
+ m_refData = CreateRefData();
+ }
+ else if ( m_refData->GetRefCount() > 1 )
+ {
+ // note that ref is not going to be destroyed in this case
+ const wxObjectRefData* ref = m_refData;
+ UnRef();
+
+ // ... so we can still access it
+ m_refData = CloneRefData(ref);
+ }
+ //else: ref count is 1, we are exclusive owners of m_refData anyhow
+
+ wxASSERT_MSG( m_refData && m_refData->GetRefCount() == 1,
+ _T("wxObject::AllocExclusive() failed.") );
+}
+
+wxObjectRefData *wxObject::CreateRefData() const
+{
+ // if you use AllocExclusive() you must override this method
+ wxFAIL_MSG( _T("CreateRefData() must be overridden if called!") );
+
+ return NULL;
+}
+
+wxObjectRefData *
+wxObject::CloneRefData(const wxObjectRefData * WXUNUSED(data)) const
+{
+ // if you use AllocExclusive() you must override this method
+ wxFAIL_MSG( _T("CloneRefData() must be overridden if called!") );
+
+ return NULL;
+}
+
+// ----------------------------------------------------------------------------
+// misc
+// ----------------------------------------------------------------------------