[cairo] cairomm RefPtr problem

Murray Cumming murrayc at murrayc.com
Wed Sep 27 11:43:01 PDT 2006


On Wed, 2006-09-27 at 08:50 +0200, Umberto Allievi wrote:
> Hello everybody,
> 
> 	I think I have discovered a problem with cast_static (and cast_dynamic,
> cast_const) member function of the RefPtr<> template class.
> 
> The original code gives me two errors error: 'int*
> Cairo::RefPtr<Caito::Context>::pCppRefcount_' is private
> 
> I think the problem is that the original code:
> 
> template <class T_CppObject>
>   template <class T_CastFrom>
> inline
> RefPtr<T_CppObject> RefPtr<T_CppObject>::cast_static(const RefPtr<T_CastFrom>& src)
> {
>   T_CppObject *const pCppObject = static_cast<T_CppObject*>(src.operator->());
> 
>   if(pCppObject && src.pCppRefcount_)
>     ++(*(src.pCppRefcount_));
> 
>   return RefPtr<T_CppObject>(pCppObject); //TODO: Does an unnecessary extra reference() on the C object.
> }
> 
> is wrong. I think it should be:
> 
> template <class T_CppObject>
>   template <class T_CastFrom>
> inline
> RefPtr<T_CppObject> RefPtr<T_CppObject>::cast_static(const RefPtr<T_CastFrom>& src)
> {
>   T_CppObject *const pCppObject = static_cast<T_CppObject*>(src.operator->());
> 
>   if(pCppObject && src.refcount_()) // pCppRefcount_ substituted with refcount_()
>     ++(*(src.refcount_()));         // idem
> 
>   return RefPtr<T_CppObject>(pCppObject); //TODO: Does an unnecessary extra reference() on the C object.
> }
> 
> And in fact this version works perfectly (the same for cast_dynamic and cast_const).
> 
> 	Thanks in advance, Umberto Allievi

Yes, I have made this change in cvs. Thanks. 

In future, please do try to create a cvs patch [1] and attach it to
bugzilla.

[1] "cvs diff -up > something.patch" after making your changes, and
editing the ChangeLog.

-- 
Murray Cumming
murrayc at murrayc.com
www.murrayc.com
www.openismus.com



More information about the cairo mailing list